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

Heyo, I need some help making this script Filtering Enabled compatible! Please help!?

Asked by 6 years ago

Hey guys! I have a script that makes a player drop their candy in this Halloween game I am making. Problem is, it doesnt work on Filtering Enabled servers. Im very new to Filtering Enabled, so if someone could tell me what to do, that'd be great! Thank you!

Here is my script


wait(.5) --Very inefficient but whatever aaa script.Parent = script.Parent.Humanoid local playeer = script.Parent.Parent.Name local player = game.Players[playeer] -------------------------------------------------------------------------------- --Put in startercharacter script.Parent.Died:connect(function() local i = math.random(1,10) if (player.leaderstats.Candy.Value - i) < 0 then i = player.leaderstats.Candy.Value end player.leaderstats.Candy.Value = player.leaderstats.Candy.Value - i -------------------------------------------------------------------------- if i ~= 0 then repeat i = i - 1 local position = script.Parent.Parent.Torso.CFrame*CFrame.new(math.random(-4,4),8,math.random(-4,4)) local Candy = game.ServerStorage.Candy:Clone() Candy:Clone() Candy.Parent = game.Workspace Candy.CFrame = position until i <= 0 ---------------------------------------------------- for i,v in pairs (script.Parent.Parent:GetChildren()) do if v:IsA("BasePart") or v:IsA("Accessory") then v:Destroy() end end end end)
0
Think about it. Client changes do not get replicated to the server. RemoteEvents are for transferring data to client and server and server to client. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

In order for your script to function correctly, you would put it in ServerScriptStorage and retrieve the player variable from a PlayerAdded event.

game.Players.PlayerAdded:Connect(function(player) --PlayerAdded event
    player.CharacterAdded:Connect(function(char) --CharacterAdded event
        char:WaitForChild("Humanoid").Died:Connect(function()
            local i = math.random(1,10) 
            if (player.leaderstats.Candy.Value - i) < 0 then
                i = player.leaderstats.Candy.Value        
            end
            player.leaderstats.Candy.Value = player.leaderstats.Candy.Value - i
            if i ~= 0 then
                local tor = char:WaitForChild("Torso")
                local pos = tor.CFrame*CFrame.new(math.random(-4,4),8,math.random(-4,4))
                repeat
                    i = i - 1
                    local Candy = game.ServerStorage.Candy:Clone()
                    Candy:Clone()
                    Candy.Parent = game.Workspace
                    Candy.CFrame = pos
                until i <= 0
                for i,v in pairs (char:GetChildren()) do
                    if v:IsA("BasePart") or v:IsA("Accessory") then
                        v:Destroy()
                    end
                end
            end
        end)
    end)
end)
0
Er, doesn't seem to work. It works in studio, but not in actual game. Am I forgetting something? QuantumWaffle 17 — 6y
0
Lines 10 and 18 would be your problem. Goulstem 8144 — 6y
0
The hierarchy to the Character object had changed. Goulstem 8144 — 6y
0
fixed mate <3 Goulstem 8144 — 6y
Ad

Answer this question