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:

01local tool = game.Players.Anderssc.Backpack.rod
02 
03local starterRod = game.Players:WaitForChild()
04 
05tool.Activated:Connect(function()
06 
07    local Rope = Instance.new("RopeConstraint", workspace)
08    Rope.Attachment0 = starterRod.Attachment0
09    Rope.Attachment1 = game.Workspace.Rope2.Attachment1
10    Rope.Visible = true
11 
12end)

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:

01local tool = script.Parent
02 
03local starterRod = game.Players:WaitForChild("starterRod") -- Change "starterRod" to whatever the thing you're waiting for's name
04 
05tool.Activated:Connect(function()
06 
07    local Rope = Instance.new("RopeConstraint", starterRod)
08    Rope.Attachment0 = starterRod.Attachment0
09    Rope.Attachment1 = game.Workspace.Rope2.Attachment1
10    Rope.Visible = true
11 
12end)

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

Ad

Answer this question