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

Filtering Enabled Not Working Help?

Asked by 7 years ago

I'm just going to use a simple script my others are not working but I thought of using this

Script that creates the value

game.Players.PlayerAdded:connect(function(plr)
    local leaderstats = Instance.new("IntValue")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr
    local BD = Instance.new("IntValue")
    BD.Parent = leaderstats
    BD.Name = "Blocks Destroyed"
    BD.Value = 0
end)

Script that Fires the Server This is a script located in game.Workspace as a part.

local hitpoints = 5
script.Parent.Touched:connect(function(hit)
    local c = hit.Parent
    print(c)
    local check = game.Players:FindFirstChild(c.Name)
    if check then
        local h = c:FindFirstChild("Humanoid")
        if h then
            hitpoints = hitpoints - 1
            h:TakeDamage(0.1)
            local ex = Instance.new("Explosion",script.Parent)
            ex.BlastPressure = 0
            ex.BlastRadius = 0
            ex.Position = script.Parent.Position
            if hitpoints <= 0 then
            script.Parent:Destroy()
            local event = game.ReplicatedStorage.Events.Leaderboard.Blocks.Blocksd
            event:FireServer()
            end
        end
    elseif hit.Parent.Name == "Bullet" then
        hitpoints = hitpoints - 1
        if hitpoints <= 0 then
            script.Parent:Destroy()
        end
    end
end)

This is the script that listens for it

script.Blocksd.OnServerEvent:connect(function(plr)
    local v = plr:FindFirstChild("leaderstats"):FindFirstChild("Blocks Destroyed")
    v.Value = v.Value + 1
end)

I received an error eventually saying FireServer can only be called from the client Help Please?

1 answer

Log in to vote
-1
Answered by 7 years ago

Only LocalScript s can call :FireServer(). You won't need to do anything special when it comes to the server if you're using a Script. The only time you need to do :FireServer() is when you are trying to get a LocalScript to change something that would need to be seen by everyone in the game, essentially anything having to do with the server.

0
Ok well I have another script that won't work and it is here ill paste it in pastebin johndeer2233 439 — 7y
0
Scripts can call FireServer as well. Its an easy way to comunicate between 2 scripts. RubenKan 3615 — 7y
Ad

Answer this question