I tried making a block where once u step on it it disables a script that makes u run and the run script is under starter GUI cuz it’s a GUI stamina script and when u step on the block it disables the script and it shows the script had been disabled but I can still run any help or help or why
Could you send us your script? It would surely help.
Yea I was about to send it rn I’m getting on my pc
local speedBoost = script.Parent
local function steppedOn(part)
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
parent.Humanoid.WalkSpeed = 30
game.StarterGui.StaminaBarGui.Enabled = false
game.StarterGui.StaminaBarGui.Sprinting.Disabled = true
end
end
speedBoost.Touched:connect(steppedOn) ```
I was using a speed block for the step on part
You need to say playergui instead of startergui
Do I need a variable for playergui
Basically what @Thanks4DaLimbs is talking about is this:
local player = game.Players:GetPlayerFromCharacter(parent)
local playerGui = player.PlayerGui
then replace game.StarterGui
with playerGui
Parent is underlined red when u out it in
local player = game.Players:GetPlayerFromCharacter(script.Parent)
local playerGui = player.PlayerGui
local playerGui = player.PlayerGui
local speedBoost = script.Parent
local function steppedOn(part)
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
parent.Humanoid.WalkSpeed = 30
game.playerGui.StaminaBarGui.Enabled = false
game.PlayerGui.StaminaBarGui.Sprinting.Disabled = true
end
end
speedBoost.Touched:connect(steppedOn) ```
thats what i have and it still dont work
Sorry for being unclear, but you need to type what I said in my other reply inside of this if statement, but make sure you replace game.StarterGui
with playerGui
I believe it would actually be this:
local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui
local speedBoost = script.Parent
local function steppedOn(part)
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
parent.Humanoid.WalkSpeed = 30
game.playerGui.StaminaBarGui.Enabled = false
game.PlayerGui.StaminaBarGui.Sprinting.Disabled = true
end
end
speedBoost.Touched:connect(steppedOn)
I think
They are using a script inside of a part (not a local script) so you can’t use game.Players.LocalPlayer
. The best way to get the player would probably be with :GetPlayerFromCharacter()
with the parent of whatever hit the part going inside of the parenthesis.
Jeez oh petes.
local speedBoost = script.Parent
local function steppedOn(part)
local parent = part.Parent
local player = game.Players:GetPlayerFromCharacter(parent)
if player then
parent.Humanoid.WalkSpeed = 30
player.PlayerGui.StaminaBarGui.Enabled = false
player.PlayerGui.StaminaBarGui.Sprinting.Disabled = true
end
end
speedBoost.Touched:Connect(steppedOn)
This is the correct way to do it.
You can’t have that in a script like @MasterObstacles said.
First off, PlayerGui is capitalized two different ways, and that’s not how you’re supposed to do it.
I’m surprised no one has noticed the capitalization on Connect (connect). do
speedBoost.Touched:Connect(steppedOn)
.
Here’s your fixed script, hopefully.
Next time when you have a problem please look at the output before coming here.