Hi, I am working on an obby game.
The game settings: Jump: 0 Walk: 0
Basically, you cannot move or jump.
local sounds = game.Workspace.Sounds local player = script.Parent.Parent.Parent.Parent local TweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new(0.2,Enum.EasingStyle.Linear) local SongFadeTweenInfo = TweenInfo.new(0.5,Enum.EasingStyle.Quad) local SongFadeOut = TweenService:Create(sounds.MainMenu,SongFadeTweenInfo,{Volume=0}) local button = script.Parent.Parent:WaitForChild("PlayButton") button.MouseEnter:Connect(function() button.Parent.Texty.Visible = true end) button.MouseLeave:Connect(function() button.Parent.Texty.Visible = false end) button.MouseButton1Click:Connect(function() local Character = game.Workspace:FindFirstChild(player.Name) script.Parent.Visible = false script.Parent.Parent.Texty.Visible = false SongFadeOut:Play() wait(2) script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.TextLabel.Visible = false game.Lighting.Blur:Destroy() Character.Humanoid.WalkSpeed = 16 Character.Humanoid.JumpPower = 50 wait(5) script.Parent.Parent.ModeSelectFrame.Visible = true script.Parent.Parent.ModeSelectBackground.Visible = true script.Parent.Parent.Texty2.Visible = true end)
This is a LocalScript in StarterGUI > Frame > TextButton
This script works fine, but the WalkSpeed and JumpPower change doesn't apply on respawn. Any help is appreciated!
If you want more information, please ask. I will answer whenever I can.
Closed since I got help from another person, still appreciated.
Here is the script:
local TweenService = game:GetService("TweenService") local sounds = game.Workspace.Sounds local player = game.Players.LocalPlayer local tweenInfo = TweenInfo.new(0.2,Enum.EasingStyle.Linear) local SongFadeTweenInfo = TweenInfo.new(0.5,Enum.EasingStyle.Quad) local SongFadeOut = TweenService:Create(sounds.MainMenu,SongFadeTweenInfo,{Volume=0}) local button = script.Parent.Parent:WaitForChild("PlayButton") function set_speed(character, walkspeed, jumppower) local humanoid = character:WaitForChild("Humanoid") humanoid.WalkSpeed = walkspeed humanoid.JumpPower = jumppower end button.MouseEnter:Connect(function() button.Parent.Texty.Visible = true end) button.MouseLeave:Connect(function() button.Parent.Texty.Visible = false end) button.MouseButton1Click:Connect(function() local Character = game.Workspace:FindFirstChild(player.Name) player.CharacterAdded:Connect(function(char) set_speed(char, 16, 50) end) script.Parent.Visible = false script.Parent.Parent.Texty.Visible = false SongFadeOut:Play() wait(2) script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.TextLabel.Visible = false game.Lighting.Blur:Destroy() set_speed(Character, 16, 50) wait(5) script.Parent.Parent.ModeSelectFrame.Visible = true script.Parent.Parent.ModeSelectBackground.Visible = true script.Parent.Parent.Texty2.Visible = true end)
Don't know how to mark my answer as a solution, but do know that I have the script fixed.
A solution to this answer would to make a datastore for your walk and jump. Here is an example of a walkspeed datastore:
local DataStore = game:GetService("DataStoreService"):GetDataStore("SpeedData") game.Players.PlayerAdded:Connect(function(Player) local speedData = DataStore:GetAsync("WalkSpeed-"..Player.UserId) local SpeedValue = Instance.new("IntValue",Player) SpeedValue.Name = "PlayerSpeed" local success,error = pcall(function() SpeedValue.Value = speedData end) if error then SpeedValue.Value = 16 end Player.CharacterAdded:Connect(function(Char) local hum = Char:WaitForChild("Humanoid") if hum then hum.WalkSpeed = SpeedValue.Value SpeedValue.Changed:Connect(function() hum.WalkSpeed = SpeedValue.Value end) end end) end) game.Players.PlayerRemoving:Connect(function(Player) local success,error = pcall(function() DataStore:SetAsync("WalkSpeed-"..Player.UserId,Player.PlayerSpeed.Value) end) if not success then warn(error) else print(success) end end)
This is just an example I found on the internet try making your own if you can this one may or may not work and you will probably need to set it up with your system Resource Hope this helps!!
It's so simple! All you gotta do is follow these steps: