Hi guys, I've written a code that works offline but doesn't work online. What I wanted to achieve is when i pressed on the clickdetector located inside my "Part", I can print "ok2" located inside StarterPack.Can anyone tell me whats wrong?:
Script inside a "Part"
btn = script.parent
clk = btn:WaitForChild("ClickDetector")
callplayerevent = game:GetService("ReplicatedStorage"):WaitForChild("CallPlayerEvent")
clk.MouseClick:connect(function(plrr)
callplayerevent:Fire(plrr)
end)
LocalScript inside "StarterPack"
player = script.Parent.Parent --Yes, I know there's a simpler way
callplayerevent = game:GetService("ReplicatedStorage"):WaitForChild("CallPlayerEvent")
callplayerevent.Event:connect(function(plr)
print("ok2")
end)
Objects I've used:
- BindableEvents named "CallPlayerEvent" located in replicatedstorage
- Part Named "SignIn"
- Click Detector named "ClickDetector" located inside "SignIn"

3 comments
Actually, I was trying to establish a communication between a "Part" in the Workspace with the Player. The script was inside "Part", so it's not a serverscript. I was trying to do this because "Part" cannot use FireServer(), as it prompts only the client could do it, resulting in me trying to do it like this: Player Clicked "Part">"Part" tells whichever player clicked on it to FireServer().
The function used in the scripts above is "FireClient", not "FireServer". FireClient is a server function that calls OnClientEvent for the player. Also, you can simply use "FireServer" in the local script if the objective is to tell the client to fire the server.
Wow thanks so much!