This line.
Change it from StarterGui to PlayerGui.
I’ll be elaborating right now
local Players = game:GetService("Players")
local coin = game.ReplicatedStorage.Coin
Players.PlayerAdded:Connect(function(Player)
local clone = coin:Clone()
clone.Parent = workspace
local gui = Player.PlayerGui.ScreenGui.TextLabel
if gui then
gui.Text = coinsVal.Value
end
clone.Touched:Connect(function(hit)
if Players:FindFirstChild(hit.Parent.Name) then
coinsVal.Value += + 1
gui.Text = coinsVal.Value
clone:Destroy()
end
end)
end)
I dont see any coinsVal here, so you’d need to define it
it said PlayerGui is not a valid member of Players “Players”
in the output and by the way i don’t want to change my script i just need a fix for the gui
Hey also can you help me with one more thing?
im trying to clone multiple coins and spawn them at random position
it all works but it doesn’t clone it multiple times it just “Teleports it” to different position
code:
local amount = game.ReplicatedStorage.Amount
repeat wait(1)
coin:Clone()
local randX = math.random(1, 500)
local randZ = math.random(1, 500)
coin.Position = Vector3.new(randX, 1, randZ)
coin.Parent = game.Workspace
amount.Value = amount.Value + 1
until
amount.Value == 20