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

Ok I understand remoteevents a bit... But what is happening here?

Ok So I'm trying to make this script fire the OpenDoor Event (there is no errors what so ever) so it can animate a door being opening or closing but it seems I can't get it to open at all.

Door

Events Script It's in ServerScriptService Under a folder called Scripts

workspace:WaitForChild('Events').OpenDoor.OnServerEvent:connect(function(Player, DoorOC)
	local CheckForTool = false
	for _,Items in pairs(Player.Character:GetChildren()) do
		if Items.ClassName == 'Tool' then
			if Items.Name == 'DoorOC' then
				CheckForTool = true
				if DoorOC then
					DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,10,0)
				else
					DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,0,0)
				end
			end
		end
	end
end)

Interact Script This is in StarterPack I might had This is suppose to Fire when clicked

		elseif Target.Parent.Name == 'Door' then
			repeat wait() until game.Players.LocalPlayer.Character
			local Magnitude = (game.Players.LocalPlayer.Character.Torso.Position - Target.Position).magnitude
			if Magnitude < 10 then	
				workspace.Events.OpenDoor:FireServer(Target.Parent)	
			end	

2 comments

0

Is the event actually happening? If you add print(Player, DoorOC) to the beginning of the server event, do you get output?

0

Yes I get Output When added around Line 2 but when I add it around Line 11 I don't get any output

1 answer

Is your script in a tool? Scripts in the Starterpack or Backpack do not get copied to the player's character when they are used. Try

workspace:WaitForChild('Events').OpenDoor.OnServerEvent:connect(function(Player, DoorOC)
    local CheckForTool = false
    for _,Items in pairs(Player.Backpack:GetChildren()) do
        if Items:IsA("Script") or Items:IsA("LocalScript") then
            if Items.Name == "DoorOC" then
                CheckForTool = true
                if DoorOC then
                    DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,10,0)
                else
                    DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,0,0)
                end
            end
        end
    end
end)

Notice the double quotes around strings. I do not believe you can use character quotes. Also, :IsA() is a nice piece of synactic sugar for doing what you did there with ClassName()

Best of luck(And skillz) --Cantos

2 comments

0

Script is not in a tool it's in StarterPack The other Events look for tool which the other ones do work.

0

What is PlayeDoorOC?

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