So my script works perfectly when I test in studio, but in-game it doesn't do anything. Anyone know why?

P.S. This script is inside a text button that is inside a scrolling frame (in a screen GUI that is in starter GUI)

local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Points
local amount = 45
local tool = game.ServerStorage:WaitForChild('Bloxiade')
local indextext = script.Parent.Text
script.Parent.MouseButton1Click:connect(function()
	if currency.Value >= 45 and not player.Backpack:FindFirstChild('Bloxiade') or player.Character:FindFirstChild('Bloxiade') then
		--They Don't Have It
		currency.Value = currency.Value - amount
		local newtool = tool:Clone()
		newtool.Parent = player.Backpack
	else
		script.Parent.Text = 'Purchase Unsuccessful'
		wait(0.5)
		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
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 = ""
end)

4 comments

0

It is a local script btw

0

Put this at the very beginning of your script: repeat wait() until game.Players.LocalPlayer;

0

add repeat wait() until game.Players.LocalPlayer

0

Wait a second, is repeat wait() until game.Player.LocalPlayer one line or two?