Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help learning about on touch events and remote events. Pls help?

2 answers

i dont know about remote events but with touched events you can do

part.Touched:Connect(function(hit) then you can do the script here if you do hit then that is the thing that hit the part so if you did print(hit.Parent.Name) if somebody walked on it, it would print their name then do end) so it would look like this

part.Touched:Connect(function(hit)
	print(hit.Parent.Name)
end)

expected output if sombody touched it would be their name.

hope this helped!

Remote Events are used to communicate between the server and the client, say I want a sword to equip when I click a button then you fire a remote event from the client to the server saying that the button has been clicked so a sword needs to be equipped. Script Examples - Remote Events

Put a remote event in replicated storage Local Script inside a Gui

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Server Script inside serverscriptservice

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
print(player)
end)

Touch Events are used to detect when somebody or something touches a part or an object.

Script Examples - Touch Events

Inside a part with a server script

script.Parent.Touched:Connect(function(hit)
-- Hit is what touched it
print(hit) -- Will most likely print left leg or something
hit.Parent.Humanoid.Health = 0 -- Kills the player
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.