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

Parts made locally issue?

So basically, I'm creating a handless tool where It spawns a "Handle" when you equip It, and gets attached to the player's arm. The problem is, since I'm using a localscript, the part is only seen by the tool wielder. Do you know how to solve It? I have been trying using ServerEvent, but for some reason, the part generated doesn't spawn, and doesnt even return an exception.

Heres the function to create the handle:


function createHandle()
	local part = Instance.new("Part")
	part.Parent = player
	part.Name = "Handle"
	part.Size = Vector3.new(0.2, 0.2, 4.08)
	part.CanCollide = false
	local mesh = Instance.new("SpecialMesh",part)
	mesh.Scale = Vector3.new(2, 2, 1.5)
	mesh.MeshId = "http://www.roblox.com/asset/?id=54983181"
	mesh.TextureId = "http://www.roblox.com/asset/?id=54983107"
	return part
end

1 comment

0

RemoteEvents are not allowed to return. You may want to use a remote function.

1 answer

The thing is, I tried using RemoteFunctions as well, but gave me the same results: nothing. No handle and not even an exception.

I have been testing with prints and I can confirm the remote function is invoked, even if it doesnt spawn the part.

Invoking the remote function in the localscript:


local handle = batEvent:InvokeServer()

Server script in the workspace:


local rStorage = game:GetService("ReplicatedStorage")
local batEvent = Instance.new("RemoteFunction", rStorage)
batEvent.Name = "batEvent"

function createHandle(player)
		local part = Instance.new("Part")
		part.Parent = player
		part.Name = "Handle"
		part.Size = Vector3.new(0.2, 0.2, 4.08)
		part.CanCollide = false
		local mesh = Instance.new("SpecialMesh",part)
		mesh.Scale = Vector3.new(2, 2, 1.5)
		mesh.MeshId = "http://www.roblox.com/asset/?id=54983181"
		mesh.TextureId = "http://www.roblox.com/asset/?id=54983107"
	return part
end

batEvent.OnServerInvoke = createHandle
		

4 comments

0

It is being created though. Test the script again and check your Player's children. Not your character model but your player in Players service.

0

Also, "calling a remote function" isn't the right terminology. "Invoke" is what you're looking for.

0

Oh my god... Yep, the handle was there. I have been struggling to solve this for hours xD. Thanks a million

0

Ur srs? The handle is still invisible for other players, even if its executed from the server x0

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