Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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.

0
Nvm I edited it SharkRayMaster 265 — 2y
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"" Stiles8353 35 — 2y
0
Accidentally marked it as answer Stiles8353 35 — 2y
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 SharkRayMaster 265 — 2y
View all comments (2 more)
0
Found out player is the first variable sent by the remote event. Stiles8353 35 — 2y
0
Yes that's literally why i said we can just get the tool THROUGH the player SharkRayMaster 265 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Player is the first variable sent by the remote event.

Answer this question