what im trying to ask is: why do i need to add remote events into rs, heres an example
part.Touched:Connect(function()
it already makes a new remote event by me adding “Touch” into the script, so why do i need to make some manually?
what im trying to ask is: why do i need to add remote events into rs, heres an example
part.Touched:Connect(function()
it already makes a new remote event by me adding “Touch” into the script, so why do i need to make some manually?
It is very unclear what you referring to specifically. A client side script could add a touch listener to a part and that event would fire on that client only. A server could add a listener and it would fire on the server only.
.Touched
isn’t a remote event though?
I think your talking about the replication roblox already handles vs using remote events?
sorry, i dont understand scripting much as im new, but how would u use a remoteevent, i need an example, if thats ok
But what exactly are you trying to do though first off
for example, to make a text change when a part is touched (ik u could easily script that but still)
Well is the text on the server your trying to change or on the client?
Because if its on the server no need for a remote event you can just used a .Touched
event and then change the text on the server
what if it was on the client, example for an obby game where the number changes when u touch a checkpoint
Well im guess you would have a leaderstats value “Stage” and when the player touches that part youu increment their Stage + 1
, and then on the client you could just have it listen for when the value changes and then it’ll update accordingly
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local stage = leaderstats:FindFirstChild("Stage")
if stage then
stage.Value = stage.Value + 1
end
end
end
end)
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local leaderstats = player:WaitForChild("leaderstats")
local stage = leaderstats:WaitForChild("Stage")
stage.Changed:Connect(function()
textLabel.Text = "Stage: ".. stage.Value
end)
So sorry, but i don’t fully understand how it works, could someone explain it in details?
I use it as a way to run a script remotely, hence the name.
So say I have a local Key detection script to check for certain keys being pressed. Instead of having to put whatever I want each key to run into that one detection script, I can use remote events to trigger them remotely. They also work as a way to detect an action locally but run a script on the server once that action has been determined
For example
local UIS = game:GetService("UserInputService")
local remote = (whatever remote you are using)
UIS.InputBegan:Connect(Function(input)
If input.KeyCode == enum.KeyCode.G then
remote:FireServer()
end
end)
This script is very bare bones and isn’t perfect but it will connect to that remote event whenever the player hits the G key. I hope this clears it up a little?
ohhhh i get it, thanks man i appreciate it
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.