Catégories
Jeu vidéo ROBLOX

Découverte mon premier jeu ROBLOX

0 Partages

Créer un Folder à votre nom pour mettre toutes vos créations :


Changer la couleur d’un part

local part = script.Parent

part.Touched:Connect(function(hit)
	part.BrickColor = BrickColor.random()
	part.Material = Enum.Material.Neon	
end)

Un part mortel :

local HumanoidFinder = require(game.ReplicatedStorage.HumanoidFinder)
local part = script.Parent
part.Touched:Connect(function(hit)
	-- On utilise la fonction du module pour tester
	local humanoid, character = HumanoidFinder.Get(hit)
	if humanoid then
		humanoid:TakeDamage(10)
	end
end)

Rendre tout petit le joueur :

local HumanoidFinder = require(game.ReplicatedStorage.HumanoidFinder)
local part = script.Parent

part.Touched:Connect(function(hit)
	-- On utilise la fonction du module pour tester
	local humanoid, character = HumanoidFinder.Get(hit)
	if humanoid then
		humanoid.BodyHeightScale.Value = 0.4
		humanoid.BodyWidthScale.Value = 0.4
		humanoid.BodyDepthScale.Value = 0.4
		humanoid.HeadScale.Value = 0.4
	end
end)

Faire glisser un part avec un clickDetector :

local part = script.Parent

local clickDetector = part.ClickDetector

clickDetector.MouseClick:Connect(function(player)
	part.Anchored = false
	part.AssemblyLinearVelocity = Vector3.new(0, 0, 50)
end)

Part pour voler avec un clickDetector :

local AntiGravity = require(game.ReplicatedStorage.AntiGravity)
local part = script.Parent 

local clickDetector = part.ClickDetector
clickDetector.MouseClick:Connect(function(player)
	part.Anchored = false
	AntiGravity.Start(part)
	part.AssemblyLinearVelocity = Vector3.new(0, 10, 10) 
end)

Téléportation d’un point A à un point B :

local HumanoidFinder = require(game.ReplicatedStorage.HumanoidFinder)
-- Ressource sur le modèle de téléportation
local teleports = script.Parent	
-- Récupération des objets sur les plateformes
local teleportA = teleports.TeleportA
local teleportB = teleports.TeleportB	

-- Quand un joueur touche la première plateforme, 
-- il est téléporté sur la seconde
-- on vérifie qu'il s'agit bien d'un personnage
teleportA.Touched:Connect(function(hit)
	local humanoid, character = HumanoidFinder.Get(hit)
	if humanoid then
		character:PivotTo(CFrame.new(teleportB.Position))
	end
end)

Grandir, Sauter, Courir plus vite :

local UserInputService = game:GetService("UserInputService")
local replicatedStorage = game:GetService("ReplicatedStorage")

local runScalePlayer = replicatedStorage:WaitForChild("RunScalePlayer")
local HumanoidFinder = require(replicatedStorage.HumanoidFinder)

local humanoid, character = HumanoidFinder.GetLocal()

local function onKeyPress(input, gameProcessed)
	if not humanoid then return end

	if input.KeyCode == Enum.KeyCode.F and not gameProcessed then
		humanoid.JumpHeight += 8
	end
	
	if input.KeyCode == Enum.KeyCode.G and not gameProcessed then
		humanoid.JumpHeight -= 8
	end

	print(input.KeyCode)
	if input.KeyCode == Enum.KeyCode.X and not gameProcessed then
		humanoid.WalkSpeed += 10
	end

	if input.KeyCode == Enum.KeyCode.Z and not gameProcessed then
		humanoid.WalkSpeed -= 10
	end
	
	if input.KeyCode == Enum.KeyCode.Q and not gameProcessed then
		runScalePlayer:FireServer(0.5)		
	end
	
	if input.KeyCode == Enum.KeyCode.E and not gameProcessed then
		runScalePlayer:FireServer(-0.5)		
	end

end

-- Connecter la fonction à l'événement InputBegan
UserInputService.InputBegan:Connect(onKeyPress)

Touches du clavier :

  • F sauter plus haut
  • G sauter moins haut
  • X courir plus vite
  • W courir moins vite
  • A grandir
  • E plus petit

Menu disponible pour le joueur :

local screenGui = script.Parent
local open = screenGui.OpenButton
local screen = screenGui.Screen
local close = screen.CloseButton
local scaleUpPlayer = screen.ScaleUpPlayerButton
local scaleDownPlayer = screen.ScaleDownPlayerButton
local runSlowerPlayer = screen.RunSlowerPlayerButton
local runFasterPlayer = screen.RunFasterPlayerButton
local jumpUpPlayer = screen.JumpUpPlayerButton
local jumpDownPlayer = screen.JumpDownPlayerButton

local replicatedStorage = game:GetService("ReplicatedStorage")
local runScalePlayer = replicatedStorage:WaitForChild("RunScalePlayer")

local runScalePlayer = replicatedStorage:WaitForChild("RunScalePlayer")
local HumanoidFinder = require(replicatedStorage.HumanoidFinder)
local StarterPlayer = game:GetService("StarterPlayer")

local humanoid, character = HumanoidFinder.GetLocal()

screen.Visible = false

open.MouseButton1Click:Connect(function()
	screen.Visible = not screen.Visible
	open.Visible = not open.Visible
end)

close.MouseButton1Click:Connect(function()
	screen.Visible = not screen.Visible
	open.Visible = not open.Visible	
end)

scaleUpPlayer.MouseButton1Click:Connect(function()
	runScalePlayer:FireServer(0.5)
end)

scaleDownPlayer.MouseButton1Click:Connect(function()
	runScalePlayer:FireServer(-0.5)
end)
		
runSlowerPlayer.MouseButton1Click:Connect(function()
	humanoid.WalkSpeed -= 10
end)

runFasterPlayer.MouseButton1Click:Connect(function()
	humanoid.WalkSpeed += 10
end)

jumpUpPlayer.MouseButton1Click:Connect(function()
	humanoid.JumpHeight += 8
end)

jumpDownPlayer.MouseButton1Click:Connect(function()
	humanoid.JumpHeight -= 8
end)

Créer une arme fatale :

Créer un objet Tool puis un part renommer Handle :

Pour réduire à l’impuissance vos adversaires :

local HumanoidFinder = require(game.ReplicatedStorage.HumanoidFinder)
local part = script.Parent

part.Touched:Connect(function(hit)
	if not hit then return end 
	
	local humanoid, character = HumanoidFinder.Get(hit)
	if humanoid then
		humanoid:TakeDamage(10)
	end
end)
0 Partages