im trying to make a card pack thing where you have to do an obby for you to get the card but i dont know how to make it so it dissapears only for the player who collected it
You could just call Destroy on it from a LocalScript
doesnt work i try to make a Fireclient but it doesnt work i cant make the touched in a local script so i have to use remote fireclient and that doesnt work cuz i dont have anything to call in it
There’s several ways you can do this. The most optimal way is simply creating a LocalScript and connecting Touched events in a for loop of all of the parts that you want to connect to.
Another way is server to client, which requires a bit of networking. You make a server-sided script that detects Touched events, and use a remote to fire to the client touching the part. Pass the part’s data to the client and manipulate the part locally.
Example:
-- Server
local Part = workspace.Part
local Remote = game.ReplicatedStorage.Remote
Part.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
Remote:FireClient(player, Part)
end)
-- Client
local Remote = game.ReplicatedStorage.Remote
Remote.OnClientEvent:Connect(function(part)
-- Part manipulation
end)
Remember that this example is demonstrating how to configure and write a server → client structure, not to be a fix for your game.
heres what i got
server:
local cardpack = game.Workspace.CardPackXD
local cardcollect = game.ReplicatedStorage.packcollect
cardpack.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
cardcollect:FireClient(player, cardpack)
local:
local cardcollect = game.ReplicatedStorage.packcollect
local plr = game.Players.LocalPlayer
cardcollect.OnClientEvent:Connect(function(player,cardpack)
cardpack:Destroy()
player.leaderstat.Potatopack1.Value = player.leaderstat.Potatopack1.Value + 1
end)
end)
still doesnt work tho
take the player argument out of the event handler in you local script, the first argument will be the “cardpack”
still doesnt work i t doesnt display any error msg
Just tried that on a new baseplate with a part called CardPackXD and all works.
If CardPackXD a part or a model? If a model then be sure to set the primary part to the part that will get touched and change it to
cardpack.PrimaryPart.Touched:Connect.......
isn’t it something like this, instead of what you did?
Remote:FireClient(Part)
Remote.OnClientEvent:Connect(function(player, part)
-- Part manipulation
end)
Here are your mistakes.
Blue underline: Incorrect passing 1st parameter.
Red underline: Exploitable data manipulation.
Blue arrows: Syntax error, bad function wrapping.
Suggestion → Read Roblox Luau documentations listed below:
https://create.roblox.com/docs/building-and-visuals/ui/leaderboard-system
https://create.roblox.com/docs/scripting/events/remote-events-and-functions
Don’t skip the fundamentals, the documentation is there for many reasons. Your issue has become more than just the title.
I think this is what he meant, but still…
Just from reading both of these:
But yeah, I still see issues with the whole thing alone.
thanks for the help but i have one question how do i make the value more secure? i dont know any other way to do this
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.