Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is it when I try to do BodyPosition.position = Vector3.new(whatever goes here) it isnt working?

Well I am not getting any errors. When the part spawns the BodyPosition goes to 0, 0, 0 for some reason. The topos is defined, I have already tried printing it. The BodyPosition is also working because if I were to move the part upwards it would glide right back down. Any solutions? Around lines 13-17 is where I think the problem is.

local serverstorage = game:GetService("ServerStorage")

function clone(player, part, position, topos)
	local magics = serverstorage.magicstuff
	local thing = magics:FindFirstChild(part)
	local magics2 = magics:GetChildren()
	for _, stuff in pairs(magics2) do
		if stuff.Name == part then
			thing = stuff
		end
	end
	if thing ~= nil then
		local parts = thing:Clone()
		parts.Parent = game.Workspace
		parts.Position = Vector3.new(position)
		local bp = parts.BodyPosition
		bp.position = Vector3.new(topos)
	else
		print 'A part is not in magicstuff'
	end
end

script.Parent.OnServerEvent:connect(clone)

2 comments

0

Sorry for the long title, it kept telling me to be specific.

0

The problem likely lies with the "topos" parameter in that it is not supplied correctly.

2 answers

✓ Accepted answer

#Case Sensitive Properties!!!

Actually, the property names are CASE SENSITIVE, so in line 17, it should be Position instead of position.

Let me fix your script:

local serverstorage = game:GetService("ServerStorage")

function clone(player, part, position, topos)
    local magics = serverstorage.magicstuff
    local thing = magics:FindFirstChild(part)
    local magics2 = magics:GetChildren()
    for _, stuff in pairs(magics2) do
        if stuff.Name == part then
            thing = stuff
        end
    end
    if thing ~= nil then
        local parts = thing:Clone()
        parts.Parent = game.Workspace
        parts.Position = Vector3.new(position)
        local bp = parts.BodyPosition
        bp.Position = Vector3.new(topos) -- HERE!!!!
    else
        print 'A part is not in magicstuff'
    end
end

script.Parent.OnServerEvent:Connect(clone) -- Also, use :Connect() instead of :connect() now!

If you have any questions, please leave a comment below! Thanks and I hope this will help!

6 comments

0

Nice eye, but it is still not working, the part still goes to 0, 0, 0

0

I see, then you should show me the script where you called the Event as well! This is because the Event fires with the position argument, and I can't see where you passed it.

0

Just posted it (as a answer)

0

Omg, let me tell you how I just fixed it. At line 17 I removed Vector3.new and then it worked.

0

You helped so i'll accept

0

Wow glad you can figure it out :) Nicely done!

Couldn't figure out how to edit my question, but this is the other script.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

function equiped()
	local plrgui = player.PlayerGui
	plrgui.SpellGui.SpellFrame.Visible = true
end

function unequiped()
	local plrgui = player.PlayerGui
	plrgui:WaitForChild("SpellGui").SpellFrame.Visible = false
end

function isequip()
	if script.Parent.Parent.Parent.ClassName == "Model" then
		return true
	else
		return false
	end
end

function change()
	if script.Parent.Parent.Parent.ClassName == "Model" then
		equiped()
	else
		unequiped()
	end
end

script.Parent.Parent.Changed:connect(change)

function mouseclick()
	local plrgui = player.PlayerGui
	local hit = mouse.Hit
	if isequip() == true then
		if plrgui.SpellGui.spelltype.Value == "Fire" then
			local magic = script.Parent.Parent.Shoot
			--magic.Position = Vector3.new(script.Parent.Parent.Shoot.Position)
			--local bg = script.BodyGyro:Clone()
			--local bp = script.BodyPosition:Clone()
			local topos = mouse.Hit.p
			--bg.Parent = magic
			--bp.Parent = magic
			--bp.Position = Vector3.new(hit.p)
			game.Workspace.Events.Cloning:FireServer("Shootf", script.Parent.Parent.Shoot.Position, topos)
		end
	end
end

mouse.Button1Down:connect(mouseclick)

This discussion is preserved as it was. New answers, comments, and votes are closed.