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

Shop GUI i created only works perfectly fine in studio but doesn't work when i play the actual game?

local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Coins
local amount = 200
local tool = game.ServerStorage:WaitForChild('LinkedSword')
local indextext = script.Parent.Text
script.Parent.MouseButton1Click:connect(function()
	if currency.Value >= amount and not player.Backpack:FindFirstChild('LinkedSword') or player.Character:FindFirstChild('LinkedSword') then
		currency.Value = currency.Value - amount		
		local newtool = tool:Clone()
		newtool.Parent = player.Backpack
		script.Parent.TextColor3 = Color3.fromRGB(11, 199, 4)
		script.Parent.Text = 'Purchase succesful!'
		wait(2)
		script.Parent.TextColor3 = Color3.fromRGB(27, 42, 53)
		script.Parent.Text = indextext
	else
		script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0)
		script.Parent.Text = 'Purchase failed, you either already have this item or do not have enough coins'
		wait(2)
		script.Parent.TextColor3 = Color3.fromRGB(27, 42, 53)
		script.Parent.Text = indextext
	end
end)

script.Parent.MouseEnter:connect(function()
	script.Parent.Parent.Parent.ProductImage.Image = 'rbxassetid://'..script.ImageValue.Value
	script.Parent.Parent.Parent.Description.Text = script.DescValue.Value
	script.Parent.Parent.Parent.ProductTitle.Text = script.TitleValue.Value
	script.Parent.Parent.Parent.SwordCost.Text = script.CostValue.Value
	script.Parent.Parent.Parent.SwordDamage.Text = script.DamageValue.Value
end)

script.Parent.MouseLeave:connect(function()
	script.Parent.Parent.Parent.ProductImage.Image = 'rbxassetid://'
	script.Parent.Parent.Parent.Description.Text = ''
	script.Parent.Parent.Parent.ProductTitle.Text = ''
	script.Parent.Parent.Parent.SwordCost.Text = ''
	script.Parent.Parent.Parent.SwordDamage.Text = ''
end)

I don't get why it doesn't work in an actual server. Anyone know why?

1 answer

✓ Accepted answer

I'm guessing this is a local script? Just a guess, but use Lighting or ReplicatedStorage instead of ServerStorage for your sword. Also, IS it "Clone" or "clone" -- I'm really sleepy right now so I'm not very sure

1 comment

0

It's both, although Clone is preferred.

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