I need help with scripting events such as remote events and on touch events. Can someone pls help? If so, message me on roblox. Thanks!
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.

3 comments
Loading...
What would you like to use remote events and touched events more? I'll post some examples, if you'd like.
https://scriptinghelpers.org/questions/94651/can-someone-help-me-understand-remote-events-they-dont-work-for-me#87427