The script is:
local part = script.Parent local model = workspace.YOOHOO function nicshere(onClick) workspace.THISNIGZ.CanCollide = false model:SetPrimaryPartCFrame(-14, -8.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -8, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -7.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -7, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -6.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -6, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -5.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -4.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -4, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -3.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -3, -129.5) wait(.1) workspace.THISNIGZ.Transparency = 1 model:SetPrimaryPartCFrame(-14, -2.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -2, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -1.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -1, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -.5, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, -0, -129.5) wait(.1) model:SetPrimaryPartCFrame(-14, 0.1, -129.5) end script.Parent.ClickDetector.MouseClick:connect(nicshere)
Before I set the script to model:Set.. it was model.Set... and I got an output error of "expected model: calling member function" and now I'm getting "Unable to cast double to CoordinateFrame"
"Cast" means "convert". A "double" is a (double-precision) number.
The error is saying that it wanted a CFrame, but got a number.
You have to make a new CFrame, and then provide that, instead of just giving numbers:
model:SetPrimaryPartCFrame(CFrame.new(-14, -0, -129.5))
but wait -- before you go and change that for every line -- use a loop!
There's a principle of programming called don't repeat yourself. Notice how your code is the same thing over and over? That's a bad thing. You can save yourself a lot of work and allow you to do more by eliminating repetition.
A for
loop is designed exactly for this. The only thing that is changing is going from -8.5
to 0
by 0.5
. It's really easy to write that into a for
loop.
for y = -8.5, 0, 0.5 do end
Read this as for each y
from -8.5
to 0
by steps of 0.5
....
for y = -8.5, 0, 0.5 do model:SetPrimaryPartCFrame(CFrame.new(-14, y, -129.5)) -- notice how I use "y" in the CFrame wait(.1) end