Help calling script to fire event to player

This script is a potion that should give experience to the player. I am having trouble connecting the give xp event to the player on the leaderboard script. Ill show the script and <— to the line I need adjusted. I will also add two screenshots, one of the error, and one of the leaderboard script that the error is referring to.


local tool = script.Parent
local debounce = false

tool.Activated:Connect(function()
	local drink = script.Parent.Handle.drink
	local smash = script.Parent.Handle.glassbreak
	
	if debounce then return end
	debounce = true
	
	game.ServerStorage.GiveXPBoss:Fire() ------ this is the line I need to conect to the player using the item.
	drink:Play()
	wait(2)
	tool.Handle.Transparency = 1
	smash:Play()
	wait(.5)
	tool:Destroy()
	
	debounce = false

end)

line 111

Have you tried removing the Name from plr.Name?

Unlike RemoteEvents, BindableEvents do not pre-define player for you. You have to do it yourself.

game.ServerStorage.GiveXPBoss:Fire(game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)) -- script.Parent.Parent is just the character model when the tool is equipped.

I just realised, did you put your RemoteEvent into serverstorage?

Thank you for this. You understood my question perfectly and your solution worked. I did not know I could define the player get character in the fire() event.

I really appreciate it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.