Settings UI is not opening

  1. What do you want to achieve? Keep it simple and clear!

Hey, so I want to make a script that when player clicks on the icon/button then it opens up a settings UI and their WalkSpeed and JumpPower will change to zero so they won’t be able to move while adjusting the settings. The if statements will check if their WS/JP is greater than zero if it is then a remote event will be fired to the server telling it to kick the player along with a reason just a security in case they attempted to do so.

  1. What is the issue? Include screenshots / videos if possible!

the issue is that the settings UI is not opening up when I clicked on the button and it showed me this error attempt to index nil with WalkSpeed

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried looking for solutions on the developer forum I also did a research on google but couldn’t find a solution.

-- LocalScript in StarterGui

local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer

local humanoid = player.Character:FindFirstChild("Humanoid")
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
if humanoid.WalkSpeed > 1  and humanoid.JumpPower then
	RemoteEvent:FireServer()
end


-- Script in ServerScriptService

local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")
local player = game.Players.PlayerAdded:Connect(function(player)
	RemoteEvent.OnServerEvent:Connect(function()
		player:Kick()
		print(player.Name .. " has been kicked out of the game for exploiting!")
	end)
end)

I would be really appreciated if someone could help me!

1 Like

You need 2 end) for this?

1 Like

That’s the function of the player and remote event.

1 Like

Oh, sorry. Which line errors?
This one:

Or this one:

Judging by the error

Where’s the part where it detects u clicking?

the error is at line 5 in a localscript

here is the full script for detecting when the button is being click and a few other things.

local Rezonate = Instance.new("Sound")
local NewFolder = Instance.new("Folder")
local RezonateSoundID = "rbxassetid://6932928276"
local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")
local SettingsButton = script.Parent.SettingsButton
local SettingsFrame = script.Parent.SettingsButton.SettingsFrame
local MusicLabel = script.Parent.SettingsButton.SettingsFrame.MusicBackground.MusicLabel
local MusicToggle = script.Parent.SettingsButton.SettingsFrame.MusicBackground.MusicToggle
local MusicBackground = script.Parent.SettingsButton.SettingsFrame.MusicBackground
local GuiToggle = script.Parent.SettingsButton.SettingsFrame.GuiBackground.GuiToggle
local GuiBackground = script.Parent.SettingsButton.SettingsFrame.GuiBackground
local ShopButton = script.Parent.SettingsButton.ShopButton
local ClickSound = game.ReplicatedStorage.Click
local MusicToggleSound = game.ReplicatedStorage.MusicToggleSound
local BlurEffect = game.Lighting.Blur
local player = game.Players.LocalPlayer
local humanoid = player.Character:FindFirstChild("Humanoid")
local canToggle = true

SettingsButton.MouseButton1Click:Connect(function()
	if SettingsFrame.Visible == false and canToggle then
		canToggle = false
		ClickSound:Play()
		humanoid.WalkSpeed = 0
		humanoid.JumpPower = 0
		if humanoid.WalkSpeed > 1 and humanoid.JumpPower then
			RemoteEvent:FireServer()
		end
		ShopButton.Visible = false
		SettingsFrame.Visible = true
		BlurEffect.Enabled = true
		SettingsFrame:TweenPosition(
			UDim2.new(17.573, 0,-7.358, 0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Sine,
			1,
			false
		)

		delay(1, function()
			canToggle = true
		end)

	elseif canToggle then
		canToggle = false

		ClickSound:Play()
		SettingsFrame:TweenPosition(
			UDim2.new(24.573, 0,-7.358, 0),
			Enum.EasingDirection.In,
			Enum.EasingStyle.Quart,
			1,
			false
		)

		delay(1, function()
			BlurEffect.Enabled = false
			ShopButton.Visible = true
			SettingsFrame.Visible = false
			player.Character:FindFirstChild("Humanoid").WalkSpeed = 16
			player.Character:FindFirstChild("Humanoid").JumpPower = 50
			canToggle = true
		end)
	end
end)

MusicToggle.MouseButton1Click:Connect(function()
	if	MusicToggle.Position == UDim2.new(0, 0,0, 0)  then

		MusicToggleSound:Play()
		MusicToggle.Position = UDim2.new(0.762, 0,0, 0)
		MusicToggle.BackgroundColor3 = Color3.fromRGB(0, 189, 91)
		MusicBackground.BackgroundColor3 = Color3.fromRGB(0, 255, 127)
		NewFolder.Name = "RezonateFolder"
		NewFolder.Parent = player
		Rezonate.Looped = true
		Rezonate.Volume = 2.5
		Rezonate.Name = "Rezonate"
		Rezonate.SoundId = RezonateSoundID
		Rezonate.Parent = player:WaitForChild("RezonateFolder")

		Rezonate:Play()

		MusicToggle.Text = "On"
		MusicLabel.Text = "Music (Activated)"
		MusicLabel.TextColor3 = Color3.fromRGB(0, 189, 91)
	else
		MusicToggleSound:Play()
		MusicToggle.Position = UDim2.new(0, 0,0, 0)
		MusicToggle.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		MusicBackground.BackgroundColor3 = Color3.fromRGB(84, 84, 84)
		MusicLabel.TextColor3 = Color3.fromRGB(170, 0, 0)
		MusicToggle.Text = "Off"
		MusicLabel.Text = "Music (De-Activated)"
		Rezonate:Stop()
	end
end)

GuiToggle.MouseButton1Click:Connect(function()
	if GuiToggle.Position == UDim2.new(0, 0,0, 0) then
		GuiToggle.Position = UDim2.new(0.762, 0,0, 0)
		MusicToggleSound:Play()
		GuiToggle.BackgroundColor3 = Color3.fromRGB(0, 189, 91)
		GuiBackground.BackgroundColor3 = Color3.fromRGB(0, 255, 127)
		GuiToggle.Text = "On"
		player.Character:FindFirstChild("Humanoid").Health = 0
		MusicToggle.Position = UDim2.new(0, 0,0, 0)
		MusicToggle.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		MusicBackground.BackgroundColor3 = Color3.fromRGB(84, 84, 84)
		NewFolder:Destroy()
		BlurEffect.Enabled = false
	end
	if SettingsFrame.Visible == true  then
		SettingsFrame.Visible = false
	end
end)

I thought it was character not Character?

image

1 Like

Try changing to

local player = game.Players.LocalPlayer
local char = player.Character or player.Character:Wait()
local humanoid = char:FindFirstChildOfClass("Humanoid")

Also I just realized that the server script could be improved to this:

local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")
RemoteEvent.OnServerEvent:Connect(function(player)
	player:Kick()
	print(player.Name .. " has been kicked out of the game for exploiting!")
end)

Is your script local script or server sided script?

local script is when it detects when the button is being click and it checks if the player WalkSpeed/JumpPower is greater than one if it is then a remote event will fire to the server script telling it to kick the player with a reason for exploiting.

You don’t need nearly as mush code as you are trying to use. All you need is a script inside of your button that has the following inside of it:

local plr = game.Players.LocalPlayer
local Humanoid = plr.Character.Humanoid

script.Parent.MouseButton1Clicked:Connect(function()
   if script.Parent.Frame.Visible = true then
      script.Parent.Frame.Visible = false
      Humanoid.WalkSpeed = --Whatever You want
      Humanoid.JumpPower = --Whatever You want
   else
      script.Parent.Frame.Visible = true
       Humanoid.WalkSpeed = 0
      Humanoid.JumpPower = 0
   end
end)

“Frame” is you Options menu, while “script.Parent” is the button

You could also use:

local plr = game.Players.PlayerAdded
local Character = plr:WaitForChild(plr.Name)
local Humanoid = Character.Humanoid

is a togglable button so I want the text to change to activate and it will play a sound and also the background of it will change color

without checking the char WalkSpeed/JumpPower and remote event will look something like this

To change the text you could use:

script.Parent.Text = "Activate"

To change the Background color you could use:

script.Parent.BackroundColor = Vector3.New(--The color you want I.e. 1, 1, 1 <-- in that state)

To play a sound make a sound put it as a child of the script and write:

script.Sound:Play()

I have many Gui so is not script.Parent only tho
image

All you have to do is make the GUI that is the parent of everything you want to change to visible or not visible and it will change all of it’s children too. For you that would be SettingsFrame.

It could be because you are not letting the character’s descendants load in, consider setting waitforchilds instead of findfirstchilds.

it said you are attempting to index nil with walkspeed == nil.walkspeed thats my reasoning.

local humanoid = player.Character:WaitForChild("Humanoid")

Okay, so I have script.Parent which is the settings button and a variable for the frame

local Frame = script.Parent.Frame

script.Parent.MouseButton1Click:Connect(function()
 script.Parent.Position 
script.Parent.BackgroundColor3
end)

Frame is the UI that is gonna show when settings button is being clicked

script.Parent.MouseButton1Click:Connect(function()
if Frame.Visible == false then
 Frame.Visible = true
end)

These variables are all one set of toggle button for the music. They are all a children of Frame and has a different name.

local SettingsButton = script.Parent.SettingsButton
local SettingsFrame = script.Parent.SettingsButton.SettingsFrame
local MusicLabel = script.Parent.SettingsButton.SettingsFrame.MusicBackground.MusicLabel
local MusicToggle = script.Parent.SettingsButton.SettingsFrame.MusicBackground.MusicToggle
local MusicBackground = script.Parent.SettingsButton.SettingsFrame.MusicBackground
local GuiToggle = script.Parent.SettingsButton.SettingsFrame.GuiBackground.GuiToggle
local GuiBackground = script.Parent.SettingsButton.SettingsFrame.GuiBackground