This shop script I made worked PERFECTLY in studio, but not at all in game? Everything was local!

local Desc = script.Parent.Parent.Parent:WaitForChild("BBGunDesc")
local OwnedOrNot = script.Parent.Parent.Parent:WaitForChild("BBGunPriceOrOwned")
local TheImage = script.Parent.Parent.Parent:WaitForChild("BBGunImage")
local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Money
local amount = 150
local tool = game.ServerStorage:WaitForChild("BBGun")
local indextext = "BBGun"
script.Parent.MouseButton1Down:connect(function()
	if currency.Value >= amount and not player.Backpack:FindFirstChild("BBGun") or player.Character:FindFirstChild("BBGun") then
		--They don't have it
		local newtool = tool:Clone()
		newtool.Parent = player.Backpack
		OwnedOrNot.Text = "BBGun - Owned"
	else
		script.Parent.Text = 'Purchase failed!'
		wait(1)
		script.Parent.Text = indextext
	end
end)

script.Parent.MouseEnter:connect(function()
	Desc.Visible = true
	OwnedOrNot.Visible = true
	TheImage.Visible = true
end)

script.Parent.MouseLeave:connect(function()
	Desc.Visible = false
	OwnedOrNot.Visible = false
	TheImage.Visible = false
end)


Please help! Thanks!

2 comments

0

Is this a local script?

0

Yea