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

local script not responding to fire client. how do i fix this?

Asked by 5 years ago

server script code:

local event = Instance.new("RemoteEvent")
event.Parent = game:GetService("ReplicatedStorage")
event.Name = "ClickEvent"

local function click (player)
 event:FireClient(player)
 print("Clicked")
end

script.Parent.ClickDetector.mouseClick:connect(click)

Note: It does print "Clicked" in output.

local script code:

local player = game:GetService("Players").LocalPlayer
local event = game:GetService("ReplicatedStorage"):WaitForChild("ClickEvent")

local function clickEvent()
 player.PlayerGui.Hosvi.Frame.Visible = true
print("epic")
end

event.OnClientEvent:Connect(clickEvent)

The local script will not run the function clickEvent even when the server script fires the client. How do I fix this?

0
Make sure both scripts are running, you can also try setting the Name before the Parent in the server. gullet 471 — 5y
0
well it is in StarterPlayerScripts, so if it isnt running than... good job roblox. SodaZere 31 — 5y
0
Use MouseClick, not mouseClick and use Connect, not connect. Also, please indent your code properly. However, it isn't as bad as some I've seen and is a shorter piece of code so it is easier to read. I will give you props for putting it in a code block, though. lunatic5 409 — 5y
0
cool but that doesnt fix the issue SodaZere 31 — 5y
View all comments (2 more)
0
We know it doesn't, but you should always have code indented properly, even if its <10 lines of code. Though un-indented code will not affect the output of your code, it's important that it's indented for the sake of readability. Messy code might hurt you as well because when you come back you'll dislike yourself. User#19524 175 — 5y
0
k but can i get help with the thing i was asking about? SodaZere 31 — 5y

Answer this question