I am trying to make a script that on respawn will bring up a GUI and position the players camera in the right spot. I also need it to set the player's JumpPower and WalkSpeed to 0. When the player dies a script will update a BoolValue. I have a separate script that should be checking if the BoolValue has updated and if so update the WalkSpeed and JumpPower. For some reason that isn't the case. Any ideas?
Script that updates the WalkSpeed and JumpPower:
local mobile = Instance.new("BoolValue", game:GetService("ReplicatedStorage"))
mobile.Name = "mobile"
mobile.Value = false
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if mobile.Value == false then
char.Humanoid.WalkSpeed = 0
char.Humanoid.JumpPower = 0
end
mobile.Value.Changed:Connect(function()
if mobile.Value == true then
char.Humanoid.WalkSpeed = 24
char.Humanoid.JumpPower = 50
elseif mobile.Value == false then
char.Humanoid.WalkSpeed = 0
char.Humanoid.WalkSpeed = 0
end
end)
end)
end)
Script that updates the BoolValue:
-- Variables
local looky = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local char = player.Character
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local storage = game:GetService("ReplicatedStorage")
local mobile = storage:WaitForChild("mobile")
-- Handles once the play button is clicked and will return the camera to normal and return the normal walkspeed and jumppower to the player
script.Parent.Playbutton.MouseButton1Click:Connect(function()
local backpack = game.Players.LocalPlayer.Backpack
for i, child in pairs(backpack:GetChildren()) do
if child:IsA("Tool") then
mobile.Value = true
script.Parent.Visible = false
repeat
wait()
looky.CameraType = Enum.CameraType.Custom
until looky.CameraType == Enum.CameraType.Custom
else
script.Parent.Parent.NoSword.Position = UDim2.new(0.321, 0,0.321, 0)
end
end
end)
hum.Died:Connect(function()
wait(5)
mobile.Value = false
repeat wait()
looky.CameraType = Enum.CameraType.Scriptable
until looky.CameraType == Enum.CameraType.Scriptable
repeat wait()
looky.CFrame = game.Workspace.startingcamerapos.CFrame
until looky.CFrame == game.Workspace.startingcamerapos.CFrame
script.Parent.Visible = true
end)
