Where did the hit.Parent came from? There’s no hit functions
You mean
local plr = game.Players:GetPlayerFromCharacter(hitpart.Parent)
?
Where did the hit.Parent came from? There’s no hit functions
You mean
local plr = game.Players:GetPlayerFromCharacter(hitpart.Parent)
?
yeah, i forgot to put in hitPart, fixed now though
Is this;
same with
plr:FindFirstChild("leaderstats").Wins.Value = plr:FindFirstChild("leaderstats").Wins.Value + 1
plr:FindFirstChild("leaderstats").Gems.Value = plr:FindFirstChild("leaderstats").Gems.Value + 5
Also, doesn’t work. I did the same thing you said
its the same thing, but in a different and easier way
Yes, it is. But well, you need to provide more information on what doesnt work. Any errors?
No errors. Do I need to bring the script in the Server Storage where the maps are located?
No, have you tagged the End Parts?
I did like what you said, I rename the Map1
What do you exactly mean by “rename the Map1”
I rename it base on my map’s name
well, if the maps are inside ServerStorage, then make this:
game:GetService("CollectionService"):AddTag(game.ServerStorage.Base.End, "endPart")
check your output, does it say anything?
Nothing related to that script. I’m sorry but I’m so confused about this. I just wanted to prevent players from getting multiple amount of currency by making it Client-Sided
Making it client sided won’t change anything. anyway, can I see the code you already put?
Why won’t it change anything? At that point, player will receive rewards and the next player whoever touches it will also receive rewards if they touch in the same time. Wait, I gonna test again
Well, 1 player would then can touch the part multiple times, making it virtually the same. If you want, you can delete the end part on the client when a player touches it.
That’s what I wanted to do, to delete the part if the player touches it but other players can still see it
You can use Debounce in that kind of situation instead of destroying the part entirely (unless theres a reason and youd prefer to destroy part for a specific player)
Well, then you could run this code on the client
local collectionService = game:GetService("CollectionService")
local endParts = collectionService:GetTagged("endPart")
--so what we're doing is getting the parts that are tagged with endPart. GetTagged returns a table of the objects that are tagged with "endPart".
for _, part in pairs(endParts) do
--this means for each end part, we run this code
part.Touched:Connect(function(hitPart)
local plr = game.Players:GetPlayerFromCharacter(hitPart.Parent)
if plr then
--found player
game.ReplicatedStorage.GetRewards:FireServer()
part:Destroy()
end
end)
end
and on the server
game.ReplicatedStorage.GetRewards.OnClientEvent:Connect(function(plr)
plr:FindFirstChild("leaderstats").Wins.Value += 1
plr:FindFirstChild("leaderstats").Gems.Value += 5
end)