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

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

Asked by 5 years ago
Edited 5 years ago

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)

0
put it in codeblock to make your code readable. Zafirua 1348 — 5y
0
Done xpertroblox3r 5 — 5y
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. valchip 789 — 5y
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 xpertroblox3r 5 — 5y
View all comments (5 more)
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. valchip 789 — 5y
0
How would I go about that? Sorry I am new. xpertroblox3r 5 — 5y
0
Delete the script u have, and a add a normal script(server-side) and paste the code there, that's it! valchip 789 — 5y
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? xpertroblox3r 5 — 5y
0
Check the answer I gave. valchip 789 — 5y

1 answer

Log in to vote
3
Answered by
valchip 789 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
It worked, cheers! xpertroblox3r 5 — 5y
0
Can you confirm that this post was answered? valchip 789 — 5y
0
Yeah It worked. If you're saying to confirm with a button I don't see it xpertroblox3r 5 — 5y
0
Take your items of out lighting and put them in replicated storage masterblokz 58 — 5y
Ad

Answer this question