I want to make a script who replace automaticly some objects when a player hit them.
But the script that i made doesn’t work and i would like to know what is wrong ??
I want to make a script who replace automaticly some objects when a player hit them.
But the script that i made doesn’t work and i would like to know what is wrong ??
I don’t believe there should be a do in the 2nd line, also please just paste the code and not screenshots.
Also on line 5 brr.Position.new, no, you do brr.Position = Vector3.new(position)
Try this:
local Part = script.Parent
Part.Touched:Connect(function(hit)
-- change whatever you wan't
end)
brr.Position = Vector3.new(x,y,z)
There is no position.new, you need vector3 because there are 3 directions in a position so you use this.
For this you need to use .Touched event.
If you want to change the position it must be a Vector3. (Vector3.new(x, y, z))
The syntax:
if condition then do
-- CODE
end
is invalid. It should be:
if condition then
-- Code
end
Your code should look like this:
local Object = script.Parent
local Debounce = false
Object.Touched:Connect(function()
if Debounce then return end -- Debouce is there to make sure the script runs once. You can remove it if you don'n need it. You can as well disconnect the event instead of using Debounce.
Debounce = true
Object.Position = Vector3.new(6.5, 13.25, 4.25)
end)
Aren’t you supposed to use Vector3 value?
local brr = script.Parent -- The Part I'm assuming
if brr.Position ~= Vector3.new(6.5,13.25,4.25) then -- Use Vector3 Values (if UI use UDim2 or UDim3)
wait(3)
brr.Position = Vector3.new(6.5, 13.25, 4.25)
end
Edit: I corrected the Syntax errors I made (Wrong capitalization)