Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
4

Unable to cast double to CoordinateFrame? (Solved)

Asked by
RoboFrog 400 Moderation Voter
9 years ago

Solution at the bottom!

Basically, whenever I run the following script, I always receive this error in the output --

Line 12: Unable to cast double to CoordinateFrame

Since there's not much explaining I can do, here's the code --

local mouse = game.Players.LocalPlayer:GetMouse()
local xcurr = game.ReplicatedStorage.CameraHandlers.Xcurr
local debounce = false

mouse.KeyDown:connect(function(key)
    if string.byte(key) == 32 then -- Space
        if not debounce then
            debounce = true
            local spawn = game.ReplicatedStorage.Model1:Clone()
            spawn.Parent = game.Workspace
            spawn.PrimaryPart = spawn:FindFirstChild("Torso")
            spawn:SetPrimaryPartCFrame(xcurr.Value, 19.9, 32.5)
            debounce = false
        end
    end
end)

I've tried replacing "xcurr.Value" with a regular number, to no avail. I've not really tampered with PrimaryPart and all of that, so I've not really developed a debugging affinity for its errors.

Thanks for reading, and I look forward to learning more on the subject.

EDIT: For anybody else who has this issue in the future, I solved this issue by doing this -- "spawn:SetPrimaryPartCFrame(CFrame.new(xcurr.Value, 19.9, 32.5))"

0
ty XxOPGUYxX1234567 221 — 4y
0
Thanks! johnoscarbhv1 137 — 2y

Answer this question