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

Why does this script only change the leaderstat with FE turned off?

Asked by 6 years ago
Edited 6 years ago

I'm trying to make this script so that it works with Filtering Enabled? are there any problems? It works when filtering is disabled.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FishEvent = ReplicatedStorage.FISHKINDEVENTS:WaitForChild("YellowFish")

local function onCreatePartFired(player)
    wait(4)
local xpamount = player.PlayerGui.Stats.EVENTS.ActivateFish.XP.Value
local coinsamount = player.PlayerGui.Stats.EVENTS.ActivateFish.Coins.Value
do

if player:findFirstChild("leaderstats") then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + game.ReplicatedStorage.PEOPLE[""..player.Name..""].FISHING.Coins.Value
player.leaderstats.XP.Value = player.leaderstats.XP.Value + game.ReplicatedStorage.PEOPLE[""..player.Name..""].FISHING.XP.Value
player.leaderstats.Fish.Value = player.leaderstats.Fish.Value + 1

end
end
end


FishEvent.OnServerEvent:Connect(onCreatePartFired)

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

I see a few things wrong so let's start from scratch

First let's get our variables in

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FishEvent = ReplicatedStorage.FISHKINDEVENTS:WaitForChild("YellowFish")

Next let's combine the function and where you call it together

FishEvent.OnServerEvent:Connect(function(plr)

end)

Now for that wait(4)

FishEvent.OnServerEvent:Connect(function(plr)
    wait(4)
end)

Now here's the part about the next two variables, you can't get inside the player's playergui from a script when FE is on. so here what i recommend Inside the localscript you are firing the server from add those two values that we need to check

event:FireServer(xpamount,coinsamount)

now lets update our current script with those variables

FishEvent.OnServerEvent:Connect(function(plr,xpamount,coinsamount)
    wait(4)
end)

now lets add our if statement with the thing you want to do

FishEvent.OnServerEvent:Connect(function(plr,xpamount,coinsamount)
    wait(4)
    if plr:findFirstChild("leaderstats") then
        plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + game.ReplicatedStorage.PEOPLE[""..plr.Name..""].FISHING.Coins.Value
        plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + game.ReplicatedStorage.PEOPLE[""..plr.Name..""].FISHING.XP.Value
        plr.leaderstats.Fish.Value = plr.leaderstats.Fish.Value + 1
    end
end)
Ad

Answer this question