Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont my remote event script with clickdetector work?

I have a jar (cookies inside) inside the jar brick is a normal script:

script.Parent.ClickDetector.MouseHoverEnter:Connect(function(p)
game.ReplicatedStorage.jarguion:FireClient()
end)

  script.Parent.ClickDetector.MouseHoverLeave:Connect(function(p)
game.ReplicatedStorage.jarguioff:FireClient()
end)

i manualy checked everthing. the remote event is there, same name(s), gui is named same thing, its there, output says:

Argument 1 missing or nil

please help, it worked before, the only difference is that this is a client event and my others are server events and they work.

5 comments

0

i also tried changing this to localscript and changing FireClient to FireServer, and added print in front of it as debug, but nothing printed after that line

0

ClickDetectors work in both server and local scripts. In your case you would just use a local script and remove the remote things.

0

ill try, btw im new to remote vents

0

doesnt work

0

It probably does not work because you put the local script in the workspace and expect it to run.

2 answers

✓ Accepted answer

General Practice

Use :GetService() to retrieve the ReplicatedStorage

Use :WaitForChild() to make sure something exists before using or changing it

Issues

The first parameter of :FireClient() is always the player instance, since the ClickDetector automatically gives you the player through its parameters, just add the variable name to the FireClient section

Revised Server Script

local remote = game:GetService("ReplicatedStorage"):WaitForChild("jarguion")
local click = script.Parent:WaitForChild("ClickDetector")

click.MouseHoverEnter:Connect(function(p)
	remote:FireClient(p)
end)

click.MouseHoverLeave:Connect(function(p)
	remote:FireClient(p)
end)

4 comments

0

OH i get it now thanks ill try

0

wait so i understand that, but now i need to know how to retrieve this, should i made normal script in starterpack "game.ReplicatedStorage.jarguion.OnServerEvent:Connect"?

0

This function would fire to the client, so you'd need a localscript that has the set-up [game:GetService("ReplicatedStorage"):WaitForChild("jarguion").OnClientEvent:Connect(function() end)]

0

As I said before ClickDetectors work in server and local script. This is incorrect to say to use remotes here. User input is managed on the client side.

i tried making normal script in starterpack:

    game.ReplicatedStorage.jarguion.OnServerEvent:Connect(function()

print("gui on")

end)

but it doesnt print that, so what now?

3 comments

0

omg i just did it XD all i did was change it to local script in starterplayerscripts, it prints now, THANKS GUY FOR TRYING :D

0

but i will answer serpent's, because he taught me one thing, :fireServer or :fireClient(and in here you put the SPECIFIC CLIENT), i didnt know before, thx

0

This should be a comment.

This discussion is preserved as it was. New answers, comments, and votes are closed.