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?

6 comments

0

Make sure both scripts are running, you can also try setting the Name before the Parent in the server.

0

well it is in StarterPlayerScripts, so if it isnt running than... good job roblox.

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.

0

cool but that doesnt fix the issue

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.

0

k but can i get help with the thing i was asking about?