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 5 years ago
Edited 5 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

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

btw this is the other script: NORMAL SCRIPT

1function onTouched(hit)
2    character = hit.Parent
3        if character then
4            game:GetService("TeleportService"):Teleport(script.Parent.Value.Value, character)
5            end
6        end
7 
8script.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 — 5y
0
How do I fix this? JustSxript 36 — 5y
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 — 5y
0
but the leaderstats work JustSxript 36 — 5y

Answer this question