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

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

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)

9 comments

0

22:04:54.006 - Character is not a valid member of DataModel

0

This script is in? (tool, part, ServerScriptService...)

0

The script is in the workspace just by itself

0

It uses a local script in starterpack and a remoteevent to activate the script

0

Change Player to plr

0

And for storage items use ServerStorage not Lighting

0

Wdym? Cause im chaning the lighting to black and white so wouldnt lighting be good?

0

Instead of lighting mean color correction 2 different ones

0

uncapitalize Character to character

1 answer

✓ Accepted answer

##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

2 comments

0

Thanks!

0

No problem!

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