Small script to use a bolean value to change the player’s speed
open a frame and change the colour of an imagelabel. It. It does change the speed, only initially but will not funciton past that.
local run = script.Parent.runnin
script.Parent.MouseButton1Click:Connect(function()
if run.Value == false then
script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 40
script.Parent.Selected.ImageColor3 = Color3.new(255, 62, 62)
run.Value = true
else
script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 18
script.Parent.Selected.ImageColor3 = Color3.new(61, 104, 122)
run.Value = false
end
end)
I think I have found you’re problem.
You see you have an image that is call “Selected” Well… that is also a boolen inside of the object called run. so you’re script thinks you’re trying to change the color of an boolen and not an object.
Just change the name of the object call “Selected” to something else and make sure you change it in the script too. also do what i said about locating the players character
do some like this to change the players walkspeed
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local SprintValue = script.Parent.runnin
script.Parent.MouseButton1Click:Connect(function()
if SprintValue.Value == false then
SprintValue.Value = true
Character:FindFirstChild("Humanoid").WalkSpeed = 40
script.Parent.Selected.ImageColor3 = Color3.new(255, 62, 62)
else
SprintValue.Value = false
Character:FindFirstChild("Humanoid").WalkSpeed = 16
script.Parent.Selected.ImageColor3 = Color3.new(61, 104, 122)--- See here the word selected need to be changed, change the name of that object
end
end)
: is bad be cause it looks like this to the script
Change it to something like this
and in the script change these lines script.Parent.Selected.ImageColor3 to this script.Parent.SprintSelectedTab.ImageColor3
local player = script:FindFirstAncestorOfClass("Player")
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local button = script.Parent
local selected = button:WaitForChild("Selected")
local run = button:WaitForChild("runnin")
button.MouseButton1Click:Connect(function()
run.Value = not run.Value
humanoid.WalkSpeed = if run.Value then 40 else 18
selected.ImageColor3 = if run.Value then Color3.new(1, 0.3, 0.3) else Color3.new(0.3, 0.5, 0.5)
end)