Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Remote events not firing?

so im making a script to fire some events based on values when a player moves but all of the sudden script stops working and doesnt fire event i tried debugging and not a single thing works.

local script:

local Player = game.Players.LocalPlayer
local Character = Player:WaitForChild("Character")
local Humanoid = Character.Humanoid
local speed = Player.stats.Speed
local equipped = Character:WaitForChild("EquippedWeight")

local VectorZero = Vector3.new(0, 0, 0)

local db = false

local function Moved()		
	if Humanoid.MoveDirection ~= VectorZero then
		if not db then
			db = true
			
			if equipped == "none" then 
				game.ReplicatedStorage.Stats.RUN:FireServer() -- fires event to add speed
				
			elseif equipped == "100lbs" then
				if speed.Value >= 100 and speed.Value < 5000 then
					game.ReplicatedStorage.Stats.RUN:FireServer()
				else
					game.ReplicatedStorage.Errors.NotWeight:FireServer() -- fires event that opens gui saying not enough stats
				end
				
			elseif equipped == "1ton" then
				if speed.Value >= 5000 and speed.Value < 500000 then
					game.ReplicatedStorage.Stats.RUN:FireServer()
				else
					game.ReplicatedStorage.Errors.NotWeight:FireServer()
				end
				
			elseif equipped == "10ton" then
				if speed.Value >= 500000 and speed.Value < 5000000 then
					game.ReplicatedStorage.Stats.RUN:FireServer()
				else
					game.ReplicatedStorage.Errors.NotWeight:FireServer()
				end
				
			end
			wait(3)
			db = false
		end
	else
	end	
end

Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(Moved) 

everything down to the last line doesnt work for some odd reason?

i dont know what im doing wrong so pls help.

server script:

game.ReplicatedStorage.Stats.RUN.OnServerEvent:connect(function(player)
	player.stats.Speed.Value = player.stats.Speed.Value + player.Character.SpeedAdd.Value
end)

4 comments

0

also sorry my scripts a little messy

1

make sure waitforchilds arent yielding anything and make sure that your script isnt disabled

0

omg thank you!! i diddnt realise that getting a yield on Character would stop my script from running but after i got rid of :WaitForChild("Character") everything started to work!

0

"Character" isn't a child of the player

1 answer

You’re comparing an instance with a string for some reason, did you mean to compare it’s value?

if equipped.Value == “none” then -- I assume it’s a StringValue
-- ...

2 comments

0

yea it is a string. also what do you mean comparing with an instance?

0

equipped is an instance or object. An instance can never be equal to a string because it’s completely another type. What you wish to do is check if the name of the instance is same as the supplied string

This discussion is preserved as it was. New answers, comments, and votes are closed.