Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

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

0

thats a typing mistake srry

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.