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

Why wont my remote event script with clickdetector work?

Asked by 5 years ago

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.

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 CommanderCaubunsia 126 — 5y
0
ClickDetectors work in both server and local scripts. In your case you would just use a local script and remove the remote things. User#5423 17 — 5y
0
ill try, btw im new to remote vents CommanderCaubunsia 126 — 5y
0
doesnt work CommanderCaubunsia 126 — 5y
0
It probably does not work because you put the local script in the workspace and expect it to run. User#5423 17 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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)
0
OH i get it now thanks ill try CommanderCaubunsia 126 — 5y
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"? CommanderCaubunsia 126 — 5y
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)] SerpentineKing 3885 — 5y
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. User#5423 17 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago

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?

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 CommanderCaubunsia 126 — 5y
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 CommanderCaubunsia 126 — 5y
0
This should be a comment. User#5423 17 — 5y

Answer this question