LOCAL SCRIPT inside of startergui
I'm making a button, when it's touched a client event fires and that part works fine but the onClientEvent function isn't working properly. I made it so when the player touches first time the ball gets inserted into workspace, the 2nd time he touches it, it makes the ball go to the position it was placed at if it moves. I used CFrame and Position to move it but they both didn't work.
local locate = true PE3.OnClientEvent:Connect(function() local activatedPart = game.ReplicatedStorage:WaitForChild("Ball") print("Button activated") local ballCopy = activatedPart:Clone() if locate == true then locate = false ballCopy.Parent = game.Workspace elseif locate == false then print("ball moving") -- this prints btw ballCopy.CFrame = CFrame.new(-3235.872, 480.378, 502.991) -- line that is not working end end)
and no there isn't any errors in the workspace, prints? yes.
ty for help
Each time the even is fired, you're cloning a new ball. Just make sure you only clone the ball once.
Ideally, you'd want to move the cloning outside the event entirely like so:
local locate = true local ballCopy = game.ReplicatedStorage:WaitForChild("Ball"):Clone() PE3.OnClientEvent:Connect(function() --... end