Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

For some reason my script identifies my tools parent as a player, yet it is not. Any advice?

This part of my local script here, (tool is defined as script.Parent), sends a signal to a remote function,

script.Parent.Equipped:Connect(function()
	
	game.ReplicatedStorage.equipstatus:FireServer(tool)
	script.Parent.equip.Value = 1
	idleanim.Priority = Enum.AnimationPriority.Action2
	idleanim.Looped = true
	idleanim:Play()
	script.Parent.scytheblade.CanCollide = false
	script.Parent.Handle.CanCollide = false
	script.Parent.scytheblade.Anchored = false
	script.Parent.Handle.Anchored = false
end)

This is the script associated with the remote event,

game.ReplicatedStorage.equipstatus.OnServerEvent:Connect(function(tool)
	tool.equip.Value = 1
end)

It errors, saying, "equip is not a valid member of Player "Players.Stiles8353" " yet my definition for tool is the local scripts parent, so how is this possible?

2 answers

Well, I don't see where you define what "tool" is

so you'd just add a variable for it

Edit: Nevermind, I see the problem now, try doing this:

· Create a variable for the player and just send it through the RemoteEvent

LocalScript:

script.Parent.Equipped:Connect(function()

	local plr = tool.Parent

	game.ReplicatedStorage.equipstatus:FireServer(plr)
	script.Parent.equip.Value = 1
	idleanim.Priority = Enum.AnimationPriority.Action2
	idleanim.Looped = true
	idleanim:Play()
	script.Parent.scytheblade.CanCollide = false
	script.Parent.Handle.CanCollide = false
	script.Parent.scytheblade.Anchored = false
	script.Parent.Handle.Anchored = false
end)

· Then we just get the tool through the player we sent

Edit 2: You just had to enter your tool's name in the script, because since I can't see how you made the tool, I don't know it's name, now, just change the toolName variable to the exact tool's name in the script below

Script:

game.ReplicatedStorage.equipstatus.OnServerEvent:Connect(function(plr)
    local toolName = "Enter the tool name here"
    local tool = plr.Character[toolName]
    tool.equip.Value = 1
end)

Since the equipstatus event is fired when equipped, the tool will be in the character, but if it was necessary we could just check for both places, the character and the player's backpack.

6 comments

0

Nvm I edited it

0

Sadly this wouldn't work anyway since scytheblade.Parent is the tool. Even so, I still get an error saying "scytheblade is not a valid member of Model "Workspace.chars.Stiles8353""

0

Accidentally marked it as answer

0

Well but, in that case, we just look for the tool, like i said, the script I gave you is just what i assumed would work but it's hard for me to make an example script when I can't even see how you made the tool, let me edit the normal script so i can make it easier for you

0

Found out player is the first variable sent by the remote event.

0

Yes that's literally why i said we can just get the tool THROUGH the player

Player is the first variable sent by the remote event.

This discussion is preserved as it was. New answers, comments, and votes are closed.