Reputation: 91
I want to make a type of a Spell that belongs to a Player, like a tool stay in Character Backpack but not literally. If a player press a button, the spell will be fired and how i can make this spell belongs to the player that pressed the button?
Upvotes: 0
Views: 72
Reputation:
When you're firing remotes from the client to the server, the first parameter of OnServerEvent
identifies the player who fired the remote. If you wanted to make a spell "belong" to a player, you could pass the Instance when firing the remote and do the actions on the server event.
Local Script
local remote = game.ReplicatedStorage:WaitForChild("FireSpell")
local spell = workspace.Spell
remote:FireServer(spell) -- fires the server with the instance passed
Server Script
local remote = game.ReplicatedStorage.FireSpell
remote.OnServerEvent:Connect(function(plr,partpassed) -- the first parameter will always be the player who fired the remote, so any parameters after define any parts passed from the client
-- do things
partpassed.Color = Color3.fromRGB(255,255,255)
end)
Upvotes: 1