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

RemoteEvent wont fire and server script wont work, no errors in the console?

Asked by 2 years ago

So, this server script won't work, No errors or anything. I want it to fire a server when a player clicks a click detector but it won't work for some reason, I'd appreciate if you would help me!

Code:

local RemoteEvent = game.ReplicatedStorage.Clothing
local Click = script.Parent
Click.MouseClick:Connect(function(Clicked)
    if Clicked.Name == game:GetService("Players").LocalPlayer then
        script.Parent.SurfaceGui.Frame.Description = Clicked.Name.."'s Avatar Booth"
        workspace.Dummy.Name = Clicked.Name
        print(Click.Name..": Claimed A Booth!")
        RemoteEvent:FireServer()
    end
end)
0
You can only fire servers with local scripts (client scripts) that way the remote fires on the client and replicates on the server. DayLighter_09 20 — 2y
0
and you need a server script to handle the server event DayLighter_09 20 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

-- local

local RemoteEvent = game.ReplicatedStorage.Clothing
local Click = script.Parent

Click.MouseClick:Connect(function(Clicked)
    if Clicked.Name == game:GetService("Players").LocalPlayer then
        RemoteEvent:FireServer()
    end
end)

-- Server

local RemoteEvent = game.ReplicatedStorage.Clothing

RemoteEvent.OnServerEvent:Connect(function()
    script.Parent.SurfaceGui.Frame.Description = Clicked.Name.."'s Avatar Booth"
        workspace.Dummy.Name = Clicked.Name
        print(Click.Name..": Claimed A Booth!")
end)

Easy as that.

Ad

Answer this question