Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

remote event can collide script wont work?

Asked by 5 years ago
Edited 5 years ago

so I'm making a script where if you have a badge it makes a certain brick's can collide property set to false only for the client, here's my script that won't work 100%

i have a number value and a script that changes the number depending on what badge you have, the local script reads it

regular script that's in the brick:

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("Remote")

remote.OnClientEvent:Connect(function(player)
    script.Parent.CanCollide = false
end)

here's the local script in the playergui and its a child of the numbervalue:

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("Remote")

if script.Parent.Value == 1 then
    remote:FireClient()
end

I don't think im using the remote right can someone tell me how i can fix it?

0
Try remote:FireServer() UPumpkin -34 — 5y
0
no luck :( retracee 68 — 5y
0
Are there any errors? UPumpkin -34 — 5y
0
no, none in the logs. thats why it's confusing retracee 68 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

Just use a local script, theres no need to use :FireClient when it is as easy as having it change the properties on the local side since it wont replicate to the server

Like you can do

script.Parent.Changed:Connect()
    if script.Parent.Value == 1 then
        script.Parent.CanCollide = false
    end
end)

It will save bandwith and doest use a while wait() do like other script that can cause lag. basically when the value changes it checks it and runs the script. hope this helped you out.

0
Dont forget about the model made by roblox that automaticly does all the ahrd work for you, thing is it may not be as organized the way you like it to be or do the same functions Sergiomontani10 236 — 5y
0
local scripts can only change the player retracee 68 — 5y
0
You didn't even connect a function properly... User#19524 175 — 5y
0
This script is not recommend to use for an FE game cause games with FE blocks local script. cherrythetree 130 — 5y
0
Yeah I know I was half asleep and scripted this in the browser dont even look at it some of the reasoning is somewhat true Sergiomontani10 236 — 5y
Ad

Answer this question