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

how to teleport a player when he clicks a button in gui?(Very Detailed Information)

Asked by 3 years ago
Edited 3 years ago

i have problems with this gui a lot so i will tell everything about it. i am making a warning gui when players coin leaderstats reach a certain amount and you use a toll to gain coins. I have a script in coins which fires a remote event which is in replicated storage and its picked up by this script. here are things you should know my gui is in starter gui all buttons have local scripts

game.ReplicatedStorage.CoinsEvent.OnServerInvoke:Connect(function(player)
if player.leaderstats.coins.Value = player.Capacity.Value then
player.PlayerGui.Warning.Frame.Visible = true
end)

this part works but i think i should tell this because i think that server thinks that gui is not on from the server side so it dosent pick up when buttons in that gui are cuz they are just on from client side. Anyways there are two buttons in the gui close and shop. My close script works so i will not mention it and here is the main problem

shop script

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
        local char = player.Character
        char.Humanoid.CFrame = CFrame.new(--Position of my shop)
end)

I hope you guys can help Thank You

EDIT:The shop script never works and does not teleport players

0
Just a note, but if you say you are using a remote event, you shouldn't be using onserverinvoke. That is for remote functions DarkDanny04 407 — 3y
0
thats a typing mistake srry typhoon1421 22 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You typed = instead of == which means equal to

if player.leaderstats.coins.Value ==  player.Capacity.Value then

char.HumanoidRootPart.CFrame = CFrame.new(--Position of my shop)
Ad

Answer this question