Catégorie : Non classé
ROBLOX suggestions :
Commentaire d’une ligne :
–print(« instruction en commentaire »)
Commentaire de plusieurs instructions :
–[[
print(« instruction en commentaire »)
print(« instruction en commentaire »)
–]]
Recherche d’une ressource dans un script :
local btOpenMenu = script.Parent.OpenButton
Comment détecter un click de la souris sur un bouton :
btOpenMenu.MouseButton1Click:Connect(function()
end)
Comment déplacer un objet Roblox :
myPart.Position += Vector3.new(10,0,0)
Déplacer un objet x fois :
for i = 1, 50 do
maPart.Position += Vector3.new(5,0,0)
wait(1)
end
Déplacer un objet Roblox tout le temps :
while true do
maPart.Position += Vector3.new(0.05,0,0)
wait(0.01)
end
Déplacer un objet jusqu’à une position :
while maPart.Position.X<60 do
maPart.Position += Vector3.new(5,0,0)
wait(0.01)
end
Synchroniser le déplacement avec le moteur de Roblox :
game:GetService(« RunService »).Heartbeat:Connect(function()
maPart.Position += Vector3.new(0.05,0,0)
end)
Comment détecter une collision du joueur avec un objet Roblox :
maPart.Touched:Connect(function(otherPart)
local character = otherPart.Parent
local player = game:GetService(« Players »):GetPlayerFromCharacter(character)
if player then
local humanoid = character:FindFirstChildWhichIsA(« Humanoid »)
if humanoid then
print(« le joueur touche le part »)
end
endend)
Comment détecter une fin de collision avec le joueur :
maPart.TouchEnded:Connect(function(otherPart)
local character = otherPart.Parent
local player = game:GetService(« Players »):GetPlayerFromCharacter(character)
if player then
local humanoid = character:FindFirstChildWhichIsA(« Humanoid »)
if humanoid then
print(« le joueur ne touche plus le part »)
end
endend)
Santé du joueur à 100 au départ du jeu :
print(humanoid.Health)
Réduire la santé du joueur :
humanoid.Health = humanoid.Health – 5
ou
humanoid:TakeDamage((5))
Le joueur meurt quand sa santé est à zéro :
humanoid.Health = 0
Comment coder un ClickDetector sur le part :

local clickDetector = script.Parent.ClickDetector
clickDetector.MouseClick:Connect(function()
print(« touché »)
end)
Comment coder un Prompt :


maPart.ProximityPrompt.Triggered:Connect(function(otherPart)
print(‘activé’)
end)


Renommer scène par niveau01

Modifier les paramètres du niveau01 dans Scènes


Clic droit de la souris sur la scène :



























Sur l’onglet Niveau01 demande par le clic droit Insérer un nouvel objet puis choisis Clavier puis Toucher :

Ton joueur marche, attend, saute, chute. Mais tu constates quand to joueur marche, il ne va que dans un sens vers la droite mais ne se retourne pas vers la gauche. Tu vas récupérer les touches du clavier pour indiquer le sens de la marche.

Puis choisis Lors de la pression d’une touche :


Puis appuis sur la touche de ton clavier pour indiquer la direction gauche :


Dans action tu vas inverser l’image :


Dans la paragraphe Apparence, tu choisis de Définir la symétrie horizontale :

