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

How come the error says Character is not a valid member of DataModel?

Asked by
Choobu 59
5 years ago
Edited 5 years ago
game:GetService("ReplicatedStorage").AwakeningEvent.OnServerEvent:Connect(function(plr, m)
local WhiteandBlack = game.Lighting.GoblinHunt
local SecondMode = game.Lighting.SecondPARTAFTERSOUND
local Sword = game.StarterPack.GoblinSlayerSword
local Player = script.Parent.Parent
local me = Player
wait()
-----------------------------------------------------------------------On the Ground saying 
 local Run = game:GetService("RunService")
local animTrack = Player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.AwawkeningMode)
animTrack:Play()
WhiteandBlack.Enabled = true
game:GetService("Chat"):Chat(Player.Character.Head, "love")
wait(2.5)
game:GetService("Chat"):Chat(Player.Character.Head, "Thats love")
wait(2.5)
game:GetService("Chat"):Chat(Player.Character.Head, "Everything Is love")
-----------------------------------------------------------------------Starts getting clearer to see and he gets up inrage
for i = 1, 4 do 
wait(0.5)
WhiteandBlack.Saturation = WhiteandBlack.Saturation + 0.05
end
game.Debris:AddItem(WhiteandBlack, 3)
WhiteandBlack:Destroy()
SecondMode.Enabled = true
end)
0
22:04:54.006 - Character is not a valid member of DataModel Choobu 59 — 5y
0
This script is in? (tool, part, ServerScriptService...) yHasteeD 1819 — 5y
0
The script is in the workspace just by itself Choobu 59 — 5y
0
It uses a local script in starterpack and a remoteevent to activate the script Choobu 59 — 5y
View all comments (5 more)
0
Change Player to plr yHasteeD 1819 — 5y
0
And for storage items use ServerStorage not Lighting yHasteeD 1819 — 5y
0
Wdym? Cause im chaning the lighting to black and white so wouldnt lighting be good? Choobu 59 — 5y
0
Instead of lighting mean color correction 2 different ones Choobu 59 — 5y
0
uncapitalize Character to character AnotherPerson_999 28 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

Question

How come the error says Character is not a valid member of DataModel?

Problem

You're indexing the player incorrectly.

local Player = script.Parent.Parent
local me = Player

I'm assuming the script is somewhere where the second iteration of .Parent leads to the Datamodel (game).

How to fix this

When you handle the OnServerEvent signal from an event the player who fired the event is passed as the first argument of the connected function.

local myEvent = ... --// assumed reference to event

local function onServerEventHandler(player, otherArguments)
    print(player, " fired the event with: ", otherArguments)
end

myEvent.OnServerEvent:Connect(onServerEventHandler)

You can get reference to the player who fired the event from the first argument. With reference to their player you can also get reference to their character. player.Character

local myEvent = ... --// assumed reference to event
local animation = ... --// assuming reference to an animation instance

local function onServerEventHandler(player, otherArguments)
    local character = player.Character
    local humanoid = character:WaitForChild("Humanoid")

    humanoid:LoadAnimation(animation):Play()
end

myEvent.OnServerEvent:Connect(onServerEventHandler)

Psssss

You should accept this answer if it helped you

0
Thanks! Choobu 59 — 5y
0
No problem! EpicMetatableMoment 1444 — 5y
Ad

Answer this question