Hi all, creating a schedule that allows you to claim things nothing particularly extravagant but after passing from the server back to the client using FIreAllClients() it only works on the client. I’ve used the same thing for other things in my game and they work absolutely fine so wondering if I could have a bit of guidance
Find scripts Below
Firing to the server
for _,ScheduleButtons in pairs(ButtonsFrame:GetDescendants()) do
if ScheduleButtons:IsA("TextButton") then
local ActivityClaimed = Functions:CreateInstance("BoolValue", ScheduleButtons.TextLabel.Text.."Claimed", ScheduleButtons)
local ActivityCounter = Player:WaitForChild("PlayerInfo"):WaitForChild("ActivityCounter")
function ActivityButtonPressed()
if ActivityClaimed.Value == false then
if ActivityCounter.Value == 3 then Functions:CreateNotification(5, "You cannot claim more than 3 activities, unclaim one!", Player) return end
local Table = {
ActivityButton = ScheduleButtons,
Value = ActivityClaimed
}
GameEvent:FireServer("ClaimingActivity", Table)
elseif ActivityClaimed.Value == true then
local Table = {
ActivityButton = ScheduleButtons,
Value = ActivityClaimed
}
GameEvent:FireServer("UnClaimingActivity", Table)
end
end
ScheduleButtons.MouseButton1Click:Connect(ActivityButtonPressed)
end
end
Server Script
GameEvent.OnServerEvent:Connect(function(Player, Event, Table)
-- other stuff before
elseif Event == "ClaimingActivity" then
local Success, ErrorMessage = pcall(function()
local Table = {
Player = Player,
ActivityButton = Table.ActivityButton
}
GameEvent:FireAllClients("ClaimedActivity", Table)
Player.PlayerInfo.ActivityCounter.Value = Player.PlayerInfo.ActivityCounter.Value + 1
end)
if not Success then
Functions:CreateNotification(5, ErrorMessage, Player)
else
Functions:CreateNotification(5, "Successfully claimed "..Table.ActivityButton.TextLabel.Text, Player)
end
-- stuff after
end)
Back to Client
GameEvent.OnClientEvent:Connect(function(Event, Table)
-- stuff before
elseif Event == "ClaimedActivity" then
local ActivityButton = Table.ActivityButton
ActivityButton.Text = "Claimed by "..tostring(Table.Player)
for _,ActivityClaimed in pairs(ActivityButton:GetChildren()) do
if ActivityClaimed:IsA("BoolValue") then
ActivityClaimed.Value = true
end
end
-- Stuff after
end)
I’m sure it’s a small issue but if I could get any help as I’m quite stuck it would be appreciated