Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remote events not firing?

Asked by 4 years ago
Edited 4 years ago

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)
0
also sorry my scripts a little messy ahsan666666666666 264 — 4y
1
make sure waitforchilds arent yielding anything and make sure that your script isnt disabled Fifkee 2017 — 4y
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! ahsan666666666666 264 — 4y
0
"Character" isn't a child of the player Spjureeedd 385 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
-- ...
0
yea it is a string. also what do you mean comparing with an instance? ahsan666666666666 264 — 4y
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 ankurbohra 681 — 4y
Ad

Answer this question