I figured out how to do it on when you click the screen, but since people keep doing it on accident, how would i make it so that it does it when you press a Button Gui? (sorry if im confusing)
game:GetService("ReplicatedStorage").Roka.OnServerEvent:Connect(function(player) local char = player.Character if not char:FindFirstChild"Rokakaka Fruit" then return end local human = char["Humanoid"] local location = player.Character.HumanoidRootPart.CFrame player:LoadCharacter() human.WalkSpeed = 16 human.JumpPower = 50 player.Character.HumanoidRootPart.CFrame = location if player.Data.Stand.Value > 1 then player.Data.Stand.Value = 1 end end)
The code you provide above is not the code responsible for actually enabling the click-on-screen function. However, I don't necessarily require it. Ensure this program below is a LocalScript, and is under the GUIButton
.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("Roka") local Button = script.Parent Button.MouseButton1Click:Connect(function() RemoteEvent:FireServer() end)
Your code also contains a lot of poor syntax practices, so I took the liberty of providing you with a cleaner program if you wish to use it:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("Roka") local function OnEvent(Player) if (Player and Player.Character) then local Character = Player.Character if (Character:FindFirstChild("Rokakaka Fruit")) then local Humanoid = Character:WaitForChild("Humanoid") local Location = Humanoid.RootPart.Position Player:LoadCharacter() Humanoid.WalKSpeed = 16 Humanoid.JumpPower = 50 Character:MoveTo(Location) if (Player.Data.Sand.Value >1) then Player.Data.Sand.Value = 1 end end end end