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

Walk speed and jump power change doesn't apply on respawn?

Asked by 1 year ago
Edited 1 year ago

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.

0
I believe the problem of this is the game starter walk speed and jump power is at 0 so when you respawn it stays like that. How can I change that? I understand the problem, just didn't knew how to fix it krLuCiEzkr 22 — 1y

3 answers

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

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.

0
put [SOLVED] or (answered) in the question title T3_MasterGamer 2189 — 1y
Ad
Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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!!

0
You really don't need a DataStore for this. This is overengineering. T3_MasterGamer 2189 — 1y
0
Good point theking66hayday 841 — 1y
0
Is this a script in ServerScriptService? Also, it would be easier if you elaborate on what you need to do. krLuCiEzkr 22 — 1y
0
Put script is server script service hope that answers it theking66hayday 841 — 1y
Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

It's so simple! All you gotta do is follow these steps:

  1. Open Roblox Studio
  2. Open the game you want to disable walk and jump.
  3. Go to the very top bar.
  4. Click Home
  5. Under Home, you will see sections of buttons.
  6. Find the Settings section, between the Test section and the Team Test section.
  7. On the Settings section, there is a button called Game Setting, and click that.
  8. On the left of the popup, you will see buttons such as Basic Info and Permissions.
  9. Find World and click it.
  10. Change Jump and "Walk* to 0.
  11. At the very bottom of the popup, click Save.
  12. Don't forget to save your game too!
0
My apologies for not elaborating, the game settings walk speed and jump power is at 0. The script purpose is to give the player walk speed and jump power back to default. However, the changes doesn't apply on respawn. (See line 32 and 33) krLuCiEzkr 22 — 1y
0
Oh, sorry for the confusion. T3_MasterGamer 2189 — 1y

Answer this question