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

How do i detect and make a variable for a player that clickes?

Asked by 3 years ago
Edited 3 years ago

So I am trying to make a fishing simulator game, but I need the line that gets created between the water and the rod, but I am stuck at the line from the player's rod, I could only make it so that the line appears between a specific player name, can anyone help me, please. Here is my code:

local tool = game.Players.Anderssc.Backpack.rod

local starterRod = game.Players:WaitForChild()

tool.Activated:Connect(function()

    local Rope = Instance.new("RopeConstraint", workspace)
    Rope.Attachment0 = starterRod.Attachment0
    Rope.Attachment1 = game.Workspace.Rope2.Attachment1
    Rope.Visible = true 

end)

1 answer

Log in to vote
0
Answered by 3 years ago

Instead of checking for a player outside of the tool, I would put this script in the tool so you wouldn't have to check the player's backpack. I would also put the RodConstraint in the starterRod and not the workspace (For organization). The code should be somewhere along the lines of this:

local tool = script.Parent

local starterRod = game.Players:WaitForChild("starterRod") -- Change "starterRod" to whatever the thing you're waiting for's name

tool.Activated:Connect(function()

    local Rope = Instance.new("RopeConstraint", starterRod)
    Rope.Attachment0 = starterRod.Attachment0
    Rope.Attachment1 = game.Workspace.Rope2.Attachment1
    Rope.Visible = true 

end)

Hope I helped! If you've got any questions on anything, just ask me in the comments.

Ad

Answer this question