error Line 5: invalid argument #2 string expected got instance
someone have an idea why this onServerEvent is not working?
note: i have this system working in another script. the difference is i’m getting player from a touched event vs sending through fireServer.
local potionEvent = game.ReplicatedStorage.remoteEvents.potionEvent
local data = game.ServerScriptService.Server.data
potionEvent.OnServerEvent:Connect(function(player)
data[player].hasFullHealthPotion = false
player.Character.Humanoid.Health = 100
print(player.Name .. ' took a full health potion and now has 100 health :)')
end)
here’s data
local data = {}
game.Players.PlayerAdded:Connect(function(player)
data[player] = {}
data[player].canHurt = true
--// potions
data[player].hasHalfHealthPotion = false
data[player].hasFullHealthPotion = true
data[player].hasSpeedPotion = false
end)
return data