Then you did something wrong different the first time. @intorsetorpolice1 is correct. Players.PlayerAdded is a signal event, not a player.
Try this script instead:
local part = script.Parent
local click = part.ClickDetector
local isClicked = false
click.MouseClick:Connect(function(Player)
if not isClicked then
isClicked = true
local playerStats = Player:FindFirstChild("leaderstats"):FindFirstChild("Coins")
part.Position += Vector3.new(0,0,5)
part.Transparency = 0.5
wait(1)
playerStats.Value += 1
part.Transparency = 1
part.CanCollide = false
end
end
thanks it worked but now how do i make this script work?
this script is supposed to destroy the ball when it hits/touches the part and after that it fires event where the game resets
local ball = game.Workspace:WaitForChild("ball!")
local part = script.Parent
local event1 = game.ReplicatedStorage.RemoteEvent
part.Touched:Connect(function(hit)
if hit.Parent == ball then
ball:Destroy()
event1:FireClient()
end
end)
yes the ball is a model and the fire event goes to this script:
so here is how the game works you click the sticks and they give you coins, when the ball hits the part the ball gets destroyed and the sticks go back into the storage of the model.
local event1 = game.ReplicatedStorage.RemoteEvent
local sticks = game.ReplicatedStorage.StickStorage
local stick = sticks:WaitForChild("Stick")
event1.OnServerEvent:Connect(function()
stick.Parent = script.Parent.sticks
end)
have you ever played “kerplunk”? well that’s basically what this game is like except with more to it… so the game you click the sticks and the sticks go to a storage in replicated storage to be out of the way so the ball can fall down, when the ball hits/touches the part the part destroys the ball and when that happens the script tells the other script to bring all the sticks back to the storage in the model to be used again.
basically the stick only one person can click it but the other players can’t click their sticks, later ill make a game mode where they can do that but that’s later when I get better at scripting.
Yeah so I would actually recommend combining the two scripts, considering only one player plays at atime.
local ball = game.Workspace:WaitForChild("ball!")
local part = script.Parent
local sticks = game.ReplicatedStorage.StickStorage
local stick = sticks:WaitForChild("Stick")
part.Touched:Connect(function(hit)
if hit.Parent == ball then
ball:Destroy()
stick.Parent = --sticks holder
end
end)