Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Value doesn't change with place teleporting?

Asked by 4 years ago
Edited 4 years ago

I am trying to use the value to teleport to a place. For some reason this script does not work!

Here is my script (its in a button of a gui) LOCAL SCRIPT

local button = script.Parent
button.MouseButton1Click:connect(function()
if game.Players.LocalPlayer.leaderstats.Coins.Value >= 5 then
game.Workspace.Tp1.tppart.Value.Value = game.Players.LocalPlayer.leaderstats.Coins.Value -5
print("Success")
script.Parent.Parent.Visible = false
else
script.Parent.Parent.TextBox.Text = ("You don't have enough coins!")
end
end)

btw this is the other script: NORMAL SCRIPT

function onTouched(hit)
    character = hit.Parent
        if character then
            game:GetService("TeleportService"):Teleport(script.Parent.Value.Value, character)
            end
        end

script.Parent.Touched:connect(onTouched)

End when the value does work then it gives a warning: Cannot teleport to invalid place id 0. Aborting teleport.

0
You shouldn't change values for leaderstats on the client. It also won't replicate to the server from the client. MrLonely1221 701 — 4y
0
How do I fix this? JustSxript 36 — 4y
1
You should use a server script in all cases to modify leaderstats. And one way to fix it is to use a RemoteEvent to fire the server, have it modify their money, then teleport if they have enough MrLonely1221 701 — 4y
0
but the leaderstats work JustSxript 36 — 4y

Answer this question