I'm trying to make a button to where you can upgrade your speed and I was testing out the value changing so the GUI would know what to say. The code that I used to set the data is below.
game.Players.PlayerAdded:Connect(function(plr)
--// Spawn Teleport
plr.CharacterAdded:Connect(function(player)
wait()
player.HumanoidRootPart.CFrame = CFrame.new(workspace.Spawn.Reference.Position)
end)
--// Leaderboard
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local KOs = Instance.new("IntValue", leaderstats)
KOs.Name = "KO's"
local KillStreak = Instance.new("IntValue", leaderstats)
KillStreak.Name = "Kill Sreak"
--// Shop Values
local shopData = Instance.new("Folder", plr)
shopData.Name = "ShopData"
local priceOwed = Instance.new("IntValue", shopData)
priceOwed.Name = "PriceOwed"
local UpgradeBought = Instance.new("StringValue", shopData)
UpgradeBought.Name = "UpgradeBought"
end)
For some reason, the script below this line can't findthe "PriceOwed" value in the folder.
script.Parent.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
local name = hit.Parent.Name
if game.Players:FindFirstChild(name) then
game.Players[name].ShopData.PriceOwed = 100
game.Players[name].ShopData.UpgradeBought = "Speed Upgrade"
game.ServerStorage.AreYouSureGUI.Parent = game.Players[name].PlayerGui
end
end
end)
Sorry for the long scripts, I tried to make it easy to read but I'm unsure if it worked as I hoped it would. Thanks in advance for helping me solve this. -Cmgtotalyawesome
