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

problem with E to interact button for the door. how do I fix?

Asked by 3 years ago
Edited by imKirda 3 years ago

so I am making a horror game, and i have been doing 3D design for a while. but I'm new to scripting. and right now the first thing I'm trying to make is an E to interact door. and i tried watching a YouTube video about how to do it, and ive even copied down the whole script, but it keeps giving me this error in the script output bar

"20:12:07.425 player is not a valid member of DataModel "haunted hallows mental hospital @ 21 Apr 2021 20:11" - Client - handle:1"

and there is a chance that its because the video i watched is from 2019, and not the most recent update, so i don't know what has changed. but this is the whole script that i have put in.

local Player = game.player.localplayer 
local Mouse = Player:GetMouse ()

local OpenDoor = game:GetService("ReplicatedStorage").OpenDoor

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        if Mouse.Target then
            OpenDoor:FireServer(Mouse.Target)
        end
    end
end)

local peeking = false

while true do
    wait()
    if Mouse.Target == workspace.door then
        if peeking == false then
            peeking = true
            local bClone = script.Parent.Button:Clone()
            bClone.parent = workspace.CurrentCamera
            bClone.Adornee = workspace.Door
            bClone.TextLable.visible = true
        end
    else
        if peeking == true then
            if workspace.CurrentCamera:FindFirstChild("Button") then
                workspace.CurrentCamera.Button:remove()
                peeking = false
            end
        end
    end
end

so if someone can help me out. i would greatly appreciate it, thanks.

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You got a typo on your very first line.

game.Players.LocalPlayer... 

not game.Player.LocalPlayer

Ad
Log in to vote
0
Answered by 3 years ago
 game.player.localplayer

Same as leedle said, the "p" in player needs to be CAPPED. So game.Player.LocalPlayer :D

Answer this question