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

Click Giver works in Studio, but published version does not, how to fix?

So the basis of my game is a simple click, you get a prompt, and an item. In the studio version, it works perfectly fine, but in the published game, you only get the prompt (from another script). I don't know how to fix this. I've tried replacing it with other versions, but NOTHING will work. Any ideas?

function onClicked(part)

local player = game.Players.LocalPlayer
local giver = game.Players:FindFirstChild(""..player.Name.."")
print("Clicked")
if player ~= nil then
local wep = game.Lighting.Key:clone() 
wep.Parent = giver.Backpack
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

9 comments

0

put it in codeblock to make your code readable.

0

Done

0

Is the script a local one or a server side one? What I mean by that is that this script is inside a normal script or a local script.

0

I believe it's local, if it was server side i'm pretty sure it would work. I do not know how to change it, or what that means entirely. I'm still new to everything and got this from digesting a video

0

Try putting the script to a server side one, I am pretty sure that is the problem. Click detectors do not work with local scripts, only server side ones.

0

How would I go about that? Sorry I am new.

0

Delete the script u have, and a add a normal script(server-side) and paste the code there, that's it!

0

I understand what you were saying now. It was already a server side script; I got confused because I've never used a local script. Any other ideas?

0

Check the answer I gave.

1 answer

Try this

function onClicked(player)
print("Clicked")
if player then
local wep = game:GetService("Lighting"):WaitForChild("Key"):Clone()
wep.Parent = player.Backpack
end
end
 
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments

0

It worked, cheers!

0

Can you confirm that this post was answered?

0

Yeah It worked. If you're saying to confirm with a button I don't see it

0

Take your items of out lighting and put them in replicated storage

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